n4s 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +2 -0
  2. package/date/package.json +9 -0
  3. package/dist/cjs/compose.development.js +9 -13
  4. package/dist/cjs/compose.js +0 -1
  5. package/dist/cjs/compose.production.js +1 -1
  6. package/dist/cjs/compounds.development.js +16 -32
  7. package/dist/cjs/compounds.js +0 -1
  8. package/dist/cjs/compounds.production.js +1 -1
  9. package/dist/cjs/date.development.js +186 -0
  10. package/dist/cjs/date.js +6 -0
  11. package/dist/cjs/date.production.js +1 -0
  12. package/dist/cjs/email.development.js +363 -0
  13. package/dist/cjs/email.js +6 -0
  14. package/dist/cjs/email.production.js +1 -0
  15. package/dist/cjs/isURL.development.js +353 -0
  16. package/dist/cjs/isURL.js +6 -0
  17. package/dist/cjs/isURL.production.js +1 -0
  18. package/dist/cjs/n4s.development.js +134 -213
  19. package/dist/cjs/n4s.js +0 -1
  20. package/dist/cjs/n4s.production.js +1 -1
  21. package/dist/cjs/schema.development.js +13 -22
  22. package/dist/cjs/schema.js +0 -1
  23. package/dist/cjs/schema.production.js +1 -1
  24. package/dist/es/compose.development.js +11 -15
  25. package/dist/es/compose.production.js +1 -1
  26. package/dist/es/compounds.development.js +16 -32
  27. package/dist/es/compounds.production.js +1 -1
  28. package/dist/es/date.development.js +184 -0
  29. package/dist/es/date.production.js +1 -0
  30. package/dist/es/email.development.js +361 -0
  31. package/dist/es/email.production.js +1 -0
  32. package/dist/es/isURL.development.js +351 -0
  33. package/dist/es/isURL.production.js +1 -0
  34. package/dist/es/n4s.development.js +155 -232
  35. package/dist/es/n4s.production.js +1 -1
  36. package/dist/es/schema.development.js +13 -20
  37. package/dist/es/schema.production.js +1 -1
  38. package/dist/umd/compose.development.js +12 -16
  39. package/dist/umd/compose.production.js +1 -1
  40. package/dist/umd/compounds.development.js +19 -35
  41. package/dist/umd/compounds.production.js +1 -1
  42. package/dist/umd/date.development.js +190 -0
  43. package/dist/umd/date.production.js +1 -0
  44. package/dist/umd/email.development.js +367 -0
  45. package/dist/umd/email.production.js +1 -0
  46. package/dist/umd/isURL.development.js +357 -0
  47. package/dist/umd/isURL.production.js +1 -0
  48. package/dist/umd/n4s.development.js +137 -216
  49. package/dist/umd/n4s.production.js +1 -1
  50. package/dist/umd/schema.development.js +16 -25
  51. package/dist/umd/schema.production.js +1 -1
  52. package/email/package.json +9 -0
  53. package/isURL/package.json +9 -0
  54. package/package.json +159 -55
  55. package/testUtils/TEnforceMock.ts +3 -0
  56. package/types/compose.d.ts +22 -23
  57. package/types/compose.d.ts.map +1 -0
  58. package/types/compounds.d.ts +22 -24
  59. package/types/compounds.d.ts.map +1 -0
  60. package/types/date.d.ts +18 -0
  61. package/types/date.d.ts.map +1 -0
  62. package/types/email.d.ts +12 -0
  63. package/types/email.d.ts.map +1 -0
  64. package/types/isURL.d.ts +12 -0
  65. package/types/isURL.d.ts.map +1 -0
  66. package/types/n4s.d.ts +30 -27
  67. package/types/n4s.d.ts.map +1 -0
  68. package/types/schema.d.ts +22 -23
  69. package/types/schema.d.ts.map +1 -0
  70. package/tsconfig.json +0 -8
@@ -1,11 +1,11 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-utils')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'n4s', 'vest-utils'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s, global['vest-utils']));
5
- }(this, (function (exports, n4s, vestUtils) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s, global["vest-utils"]));
5
+ })(this, (function (exports, n4s, vestUtils) { 'use strict';
6
6
 
7
7
  function ruleReturn(pass, message) {
8
- var output = { pass: pass };
8
+ const output = { pass };
9
9
  if (message) {
10
10
  output.message = message;
11
11
  }
@@ -31,27 +31,20 @@
31
31
  }
32
32
 
33
33
  function isArrayOf(inputArray, currentRule) {
34
- return defaultToPassing(vestUtils.mapFirst(inputArray, function (currentValue, breakout, index) {
35
- var res = n4s.ctx.run({ value: currentValue, set: true, meta: { index: index } }, function () { return runLazyRule(currentRule, currentValue); });
34
+ return defaultToPassing(vestUtils.mapFirst(inputArray, (currentValue, breakout, index) => {
35
+ const res = n4s.ctx.run({ value: currentValue, set: true, meta: { index } }, () => runLazyRule(currentRule, currentValue));
36
36
  breakout(!res.pass, res);
37
37
  }));
38
38
  }
39
39
 
40
40
  function loose(inputObject, shapeObject) {
41
- var _loop_1 = function (key) {
42
- var currentValue = inputObject[key];
43
- var currentRule = shapeObject[key];
44
- var res = n4s.ctx.run({ value: currentValue, set: true, meta: { key: key } }, function () {
45
- return runLazyRule(currentRule, currentValue);
46
- });
41
+ for (const key in shapeObject) {
42
+ const currentValue = inputObject[key];
43
+ const currentRule = shapeObject[key];
44
+ const res = n4s.ctx.run({ value: currentValue, set: true, meta: { key } }, () => runLazyRule(currentRule, currentValue));
47
45
  if (!res.pass) {
48
- return { value: res };
46
+ return res;
49
47
  }
50
- };
51
- for (var key in shapeObject) {
52
- var state_1 = _loop_1(key);
53
- if (typeof state_1 === "object")
54
- return state_1.value;
55
48
  }
56
49
  return passing();
57
50
  }
@@ -64,11 +57,11 @@
64
57
  }
65
58
 
66
59
  function shape(inputObject, shapeObject) {
67
- var baseRes = loose(inputObject, shapeObject);
60
+ const baseRes = loose(inputObject, shapeObject);
68
61
  if (!baseRes.pass) {
69
62
  return baseRes;
70
63
  }
71
- for (var key in inputObject) {
64
+ for (const key in inputObject) {
72
65
  if (!vestUtils.hasOwnProperty(shapeObject, key)) {
73
66
  return failing();
74
67
  }
@@ -79,17 +72,15 @@
79
72
  // Help needed improving the typings of this file.
80
73
  // Ideally, we'd be able to extend ShapeObject, but that's not possible.
81
74
  function partial(shapeObject) {
82
- var output = {};
83
- for (var key in shapeObject) {
75
+ const output = {};
76
+ for (const key in shapeObject) {
84
77
  output[key] = n4s.enforce.optional(shapeObject[key]);
85
78
  }
86
79
  return output;
87
80
  }
88
81
 
89
- n4s.enforce.extend({ isArrayOf: isArrayOf, loose: loose, optional: optional, shape: shape });
82
+ n4s.enforce.extend({ isArrayOf, loose, optional, shape });
90
83
 
91
84
  exports.partial = partial;
92
85
 
93
- Object.defineProperty(exports, '__esModule', { value: true });
94
-
95
- })));
86
+ }));
@@ -1 +1 @@
1
- "use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).schema={},e.n4s,e["vest-utils"])}(this,(function(e,n,t){function r(e,n){return e={pass:e},n&&(e.message=n),e}function u(e,n){try{return e.run(n)}catch(e){return r(!1)}}function i(e,t){var i,o=function(r){var i=e[r],o=t[r];if(!(r=n.ctx.run({value:i,set:!0,meta:{key:r}},(function(){return u(o,i)}))).pass)return{value:r}};for(i in t){var s=o(i);if("object"==typeof s)return s.value}return r(!0)}n.enforce.extend({isArrayOf:function(e,i){return t.defaultTo(t.mapFirst(e,(function(e,t,r){t(!(r=n.ctx.run({value:e,set:!0,meta:{index:r}},(function(){return u(i,e)}))).pass,r)})),r(!0))},loose:i,optional:function(e,n){return t.isNullish(e)?r(!0):u(n,e)},shape:function(e,n){var u=i(e,n);if(!u.pass)return u;for(var o in e)if(!t.hasOwnProperty(n,o))return r(!1);return r(!0)}}),e.partial=function(e){var t,r={};for(t in e)r[t]=n.enforce.optional(e[t]);return r},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).schema={},n.n4s,n["vest-utils"])}(this,(function(n,t,e){"use strict";function r(n,t){const e={pass:n};return t&&(e.message=t),e}function s(){return r(!1)}function o(){return r(!0)}function u(n,t){try{return n.run(t)}catch(n){return s()}}function i(n,e){for(const r in e){const s=n[r],o=e[r],i=t.ctx.run({value:s,set:!0,meta:{key:r}},(()=>u(o,s)));if(!i.pass)return i}return o()}t.enforce.extend({isArrayOf:function(n,r){return s=e.mapFirst(n,((n,e,s)=>{const o=t.ctx.run({value:n,set:!0,meta:{index:s}},(()=>u(r,n)));e(!o.pass,o)})),e.defaultTo(s,o());var s},loose:i,optional:function(n,t){return e.isNullish(n)?o():u(t,n)},shape:function(n,t){const r=i(n,t);if(!r.pass)return r;for(const r in n)if(!e.hasOwnProperty(t,r))return s();return o()}}),n.partial=function(n){const e={};for(const r in n)e[r]=t.enforce.optional(n[r]);return e}}));
@@ -0,0 +1,9 @@
1
+ {
2
+ "main": "../dist/cjs/email.js",
3
+ "module": "../dist/es/email.production.js",
4
+ "unpkg": "../dist/umd/email.production.js",
5
+ "jsdelivr": "../dist/umd/email.production.js",
6
+ "name": "email",
7
+ "types": "../types/email.d.ts",
8
+ "private": true
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "main": "../dist/cjs/isURL.js",
3
+ "module": "../dist/es/isURL.production.js",
4
+ "unpkg": "../dist/umd/isURL.production.js",
5
+ "jsdelivr": "../dist/umd/isURL.production.js",
6
+ "name": "isURL",
7
+ "types": "../types/isURL.d.ts",
8
+ "private": true
9
+ }
package/package.json CHANGED
@@ -1,49 +1,153 @@
1
1
  {
2
- "version": "5.0.0",
2
+ "version": "5.0.2",
3
3
  "license": "MIT",
4
4
  "main": "./dist/cjs/n4s.js",
5
5
  "types": "./types/n4s.d.ts",
6
6
  "name": "n4s",
7
7
  "author": "ealush",
8
+ "description": "Assertion library for form validations",
9
+ "keywords": [
10
+ "vest",
11
+ "enforce",
12
+ "n4s",
13
+ "validation"
14
+ ],
8
15
  "scripts": {
9
16
  "test": "vx test",
10
17
  "release": "vx release"
11
18
  },
12
19
  "dependencies": {
13
- "context": "^3.0.0",
14
- "vest-utils": "^0.0.2"
20
+ "context": "^3.0.10",
21
+ "vest-utils": "^1.0.1"
15
22
  },
23
+ "devDependencies": {
24
+ "@types/validator": "^13.7.17",
25
+ "validator": "^13.9.0"
26
+ },
27
+ "vxAllowResolve": [
28
+ "validator"
29
+ ],
16
30
  "module": "./dist/es/n4s.production.js",
17
31
  "exports": {
18
- "./compose": {
32
+ "./schema": {
19
33
  "production": {
20
- "types": "./types/compose.d.ts",
21
- "browser": "./dist/es/compose.production.js",
22
- "umd": "./dist/umd/compose.production.js",
23
- "import": "./dist/es/compose.production.js",
24
- "require": "./dist/cjs/compose.production.js",
25
- "node": "./dist/cjs/compose.production.js",
26
- "module": "./dist/es/compose.production.js",
27
- "default": "./dist/cjs/compose.production.js"
34
+ "types": "./types/schema.d.ts",
35
+ "browser": "./dist/es/schema.production.js",
36
+ "umd": "./dist/umd/schema.production.js",
37
+ "import": "./dist/es/schema.production.js",
38
+ "require": "./dist/cjs/schema.production.js",
39
+ "node": "./dist/cjs/schema.production.js",
40
+ "module": "./dist/es/schema.production.js",
41
+ "default": "./dist/cjs/schema.production.js"
28
42
  },
29
43
  "development": {
30
- "types": "./types/compose.d.ts",
31
- "browser": "./dist/es/compose.development.js",
32
- "umd": "./dist/umd/compose.development.js",
33
- "import": "./dist/es/compose.development.js",
34
- "require": "./dist/cjs/compose.development.js",
35
- "node": "./dist/cjs/compose.development.js",
36
- "module": "./dist/es/compose.development.js",
37
- "default": "./dist/cjs/compose.development.js"
44
+ "types": "./types/schema.d.ts",
45
+ "browser": "./dist/es/schema.development.js",
46
+ "umd": "./dist/umd/schema.development.js",
47
+ "import": "./dist/es/schema.development.js",
48
+ "require": "./dist/cjs/schema.development.js",
49
+ "node": "./dist/cjs/schema.development.js",
50
+ "module": "./dist/es/schema.development.js",
51
+ "default": "./dist/cjs/schema.development.js"
38
52
  },
39
- "types": "./types/compose.d.ts",
40
- "browser": "./dist/es/compose.production.js",
41
- "umd": "./dist/umd/compose.production.js",
42
- "import": "./dist/es/compose.production.js",
43
- "require": "./dist/cjs/compose.production.js",
44
- "node": "./dist/cjs/compose.production.js",
45
- "module": "./dist/es/compose.production.js",
46
- "default": "./dist/cjs/compose.production.js"
53
+ "types": "./types/schema.d.ts",
54
+ "browser": "./dist/es/schema.production.js",
55
+ "umd": "./dist/umd/schema.production.js",
56
+ "import": "./dist/es/schema.production.js",
57
+ "require": "./dist/cjs/schema.production.js",
58
+ "node": "./dist/cjs/schema.production.js",
59
+ "module": "./dist/es/schema.production.js",
60
+ "default": "./dist/cjs/schema.production.js"
61
+ },
62
+ "./isURL": {
63
+ "production": {
64
+ "types": "./types/isURL.d.ts",
65
+ "browser": "./dist/es/isURL.production.js",
66
+ "umd": "./dist/umd/isURL.production.js",
67
+ "import": "./dist/es/isURL.production.js",
68
+ "require": "./dist/cjs/isURL.production.js",
69
+ "node": "./dist/cjs/isURL.production.js",
70
+ "module": "./dist/es/isURL.production.js",
71
+ "default": "./dist/cjs/isURL.production.js"
72
+ },
73
+ "development": {
74
+ "types": "./types/isURL.d.ts",
75
+ "browser": "./dist/es/isURL.development.js",
76
+ "umd": "./dist/umd/isURL.development.js",
77
+ "import": "./dist/es/isURL.development.js",
78
+ "require": "./dist/cjs/isURL.development.js",
79
+ "node": "./dist/cjs/isURL.development.js",
80
+ "module": "./dist/es/isURL.development.js",
81
+ "default": "./dist/cjs/isURL.development.js"
82
+ },
83
+ "types": "./types/isURL.d.ts",
84
+ "browser": "./dist/es/isURL.production.js",
85
+ "umd": "./dist/umd/isURL.production.js",
86
+ "import": "./dist/es/isURL.production.js",
87
+ "require": "./dist/cjs/isURL.production.js",
88
+ "node": "./dist/cjs/isURL.production.js",
89
+ "module": "./dist/es/isURL.production.js",
90
+ "default": "./dist/cjs/isURL.production.js"
91
+ },
92
+ "./email": {
93
+ "production": {
94
+ "types": "./types/email.d.ts",
95
+ "browser": "./dist/es/email.production.js",
96
+ "umd": "./dist/umd/email.production.js",
97
+ "import": "./dist/es/email.production.js",
98
+ "require": "./dist/cjs/email.production.js",
99
+ "node": "./dist/cjs/email.production.js",
100
+ "module": "./dist/es/email.production.js",
101
+ "default": "./dist/cjs/email.production.js"
102
+ },
103
+ "development": {
104
+ "types": "./types/email.d.ts",
105
+ "browser": "./dist/es/email.development.js",
106
+ "umd": "./dist/umd/email.development.js",
107
+ "import": "./dist/es/email.development.js",
108
+ "require": "./dist/cjs/email.development.js",
109
+ "node": "./dist/cjs/email.development.js",
110
+ "module": "./dist/es/email.development.js",
111
+ "default": "./dist/cjs/email.development.js"
112
+ },
113
+ "types": "./types/email.d.ts",
114
+ "browser": "./dist/es/email.production.js",
115
+ "umd": "./dist/umd/email.production.js",
116
+ "import": "./dist/es/email.production.js",
117
+ "require": "./dist/cjs/email.production.js",
118
+ "node": "./dist/cjs/email.production.js",
119
+ "module": "./dist/es/email.production.js",
120
+ "default": "./dist/cjs/email.production.js"
121
+ },
122
+ "./date": {
123
+ "production": {
124
+ "types": "./types/date.d.ts",
125
+ "browser": "./dist/es/date.production.js",
126
+ "umd": "./dist/umd/date.production.js",
127
+ "import": "./dist/es/date.production.js",
128
+ "require": "./dist/cjs/date.production.js",
129
+ "node": "./dist/cjs/date.production.js",
130
+ "module": "./dist/es/date.production.js",
131
+ "default": "./dist/cjs/date.production.js"
132
+ },
133
+ "development": {
134
+ "types": "./types/date.d.ts",
135
+ "browser": "./dist/es/date.development.js",
136
+ "umd": "./dist/umd/date.development.js",
137
+ "import": "./dist/es/date.development.js",
138
+ "require": "./dist/cjs/date.development.js",
139
+ "node": "./dist/cjs/date.development.js",
140
+ "module": "./dist/es/date.development.js",
141
+ "default": "./dist/cjs/date.development.js"
142
+ },
143
+ "types": "./types/date.d.ts",
144
+ "browser": "./dist/es/date.production.js",
145
+ "umd": "./dist/umd/date.production.js",
146
+ "import": "./dist/es/date.production.js",
147
+ "require": "./dist/cjs/date.production.js",
148
+ "node": "./dist/cjs/date.production.js",
149
+ "module": "./dist/es/date.production.js",
150
+ "default": "./dist/cjs/date.production.js"
47
151
  },
48
152
  "./compounds": {
49
153
  "production": {
@@ -75,35 +179,35 @@
75
179
  "module": "./dist/es/compounds.production.js",
76
180
  "default": "./dist/cjs/compounds.production.js"
77
181
  },
78
- "./schema": {
182
+ "./compose": {
79
183
  "production": {
80
- "types": "./types/schema.d.ts",
81
- "browser": "./dist/es/schema.production.js",
82
- "umd": "./dist/umd/schema.production.js",
83
- "import": "./dist/es/schema.production.js",
84
- "require": "./dist/cjs/schema.production.js",
85
- "node": "./dist/cjs/schema.production.js",
86
- "module": "./dist/es/schema.production.js",
87
- "default": "./dist/cjs/schema.production.js"
184
+ "types": "./types/compose.d.ts",
185
+ "browser": "./dist/es/compose.production.js",
186
+ "umd": "./dist/umd/compose.production.js",
187
+ "import": "./dist/es/compose.production.js",
188
+ "require": "./dist/cjs/compose.production.js",
189
+ "node": "./dist/cjs/compose.production.js",
190
+ "module": "./dist/es/compose.production.js",
191
+ "default": "./dist/cjs/compose.production.js"
88
192
  },
89
193
  "development": {
90
- "types": "./types/schema.d.ts",
91
- "browser": "./dist/es/schema.development.js",
92
- "umd": "./dist/umd/schema.development.js",
93
- "import": "./dist/es/schema.development.js",
94
- "require": "./dist/cjs/schema.development.js",
95
- "node": "./dist/cjs/schema.development.js",
96
- "module": "./dist/es/schema.development.js",
97
- "default": "./dist/cjs/schema.development.js"
194
+ "types": "./types/compose.d.ts",
195
+ "browser": "./dist/es/compose.development.js",
196
+ "umd": "./dist/umd/compose.development.js",
197
+ "import": "./dist/es/compose.development.js",
198
+ "require": "./dist/cjs/compose.development.js",
199
+ "node": "./dist/cjs/compose.development.js",
200
+ "module": "./dist/es/compose.development.js",
201
+ "default": "./dist/cjs/compose.development.js"
98
202
  },
99
- "types": "./types/schema.d.ts",
100
- "browser": "./dist/es/schema.production.js",
101
- "umd": "./dist/umd/schema.production.js",
102
- "import": "./dist/es/schema.production.js",
103
- "require": "./dist/cjs/schema.production.js",
104
- "node": "./dist/cjs/schema.production.js",
105
- "module": "./dist/es/schema.production.js",
106
- "default": "./dist/cjs/schema.production.js"
203
+ "types": "./types/compose.d.ts",
204
+ "browser": "./dist/es/compose.production.js",
205
+ "umd": "./dist/umd/compose.production.js",
206
+ "import": "./dist/es/compose.production.js",
207
+ "require": "./dist/cjs/compose.production.js",
208
+ "node": "./dist/cjs/compose.production.js",
209
+ "module": "./dist/es/compose.production.js",
210
+ "default": "./dist/cjs/compose.production.js"
107
211
  },
108
212
  ".": {
109
213
  "development": {
@@ -126,7 +230,7 @@
126
230
  "default": "./dist/cjs/n4s.production.js"
127
231
  },
128
232
  "./package.json": "./package.json",
129
- "./": "./"
233
+ "./*": "./*"
130
234
  },
131
235
  "repository": {
132
236
  "type": "git",
@@ -138,4 +242,4 @@
138
242
  },
139
243
  "unpkg": "./dist/umd/n4s.production.js",
140
244
  "jsdelivr": "./dist/umd/n4s.production.js"
141
- }
245
+ }
@@ -0,0 +1,3 @@
1
+ import { enforce } from 'n4s';
2
+
3
+ export type TEnforceMock = typeof enforce;
@@ -1,9 +1,4 @@
1
- type DropFirst<T extends unknown[]> = T extends [
2
- unknown,
3
- ...infer U
4
- ] ? U : never;
5
- type Stringable = string | ((...args: any[]) => string);
6
- type CB = (...args: any[]) => any;
1
+ import { CB, Stringable, DynamicValue, DropFirst, BlankValue } from "vest-utils";
7
2
  type RuleReturn = boolean | {
8
3
  pass: boolean;
9
4
  message?: Stringable;
@@ -21,7 +16,7 @@ declare function equals(value: unknown, arg1: unknown): boolean;
21
16
  declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
22
17
  declare function inside(value: unknown, arg1: string | unknown[]): boolean;
23
18
  declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
24
- declare function isBlank(value: unknown): boolean;
19
+ declare function isBlank(value: unknown): value is BlankValue;
25
20
  declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
26
21
  declare function isNaN(value: unknown): boolean;
27
22
  declare function isNegative(value: number | string): boolean;
@@ -41,16 +36,16 @@ declare const baseRules: {
41
36
  doesNotStartWith: (value: string, arg1: string) => boolean;
42
37
  endsWith: typeof endsWith;
43
38
  equals: typeof equals;
44
- greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
39
+ greaterThan: typeof import("vest-utils").greaterThan;
45
40
  greaterThanOrEquals: typeof greaterThanOrEquals;
46
- gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
41
+ gt: typeof import("vest-utils").greaterThan;
47
42
  gte: typeof greaterThanOrEquals;
48
43
  inside: typeof inside;
49
- isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
44
+ isArray: typeof import("vest-utils").isArray;
50
45
  isBetween: typeof isBetween;
51
46
  isBlank: typeof isBlank;
52
- isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
53
- isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
47
+ isBoolean: typeof import("vest-utils").isBoolean;
48
+ isEmpty: typeof import("vest-utils").isEmpty;
54
49
  isEven: (value: any) => boolean;
55
50
  isFalsy: (value: unknown) => boolean;
56
51
  isKeyOf: typeof isKeyOf;
@@ -70,21 +65,21 @@ declare const baseRules: {
70
65
  isNotString: (v: unknown) => boolean;
71
66
  isNotUndefined: (value?: unknown) => boolean;
72
67
  isNotValueOf: (value: any, objectToCheck: any) => boolean;
73
- isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
74
- isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
68
+ isNull: typeof import("vest-utils").isNull;
69
+ isNullish: typeof import("vest-utils").isNullish;
75
70
  isNumber: typeof isNumber;
76
- isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
71
+ isNumeric: typeof import("vest-utils").isNumeric;
77
72
  isOdd: (value: any) => boolean;
78
- isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
79
- isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
73
+ isPositive: typeof import("vest-utils").isPositive;
74
+ isString: typeof import("vest-utils").isStringValue;
80
75
  isTruthy: typeof isTruthy;
81
- isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
76
+ isUndefined: typeof import("vest-utils").isUndefined;
82
77
  isValueOf: typeof isValueOf;
83
- lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
78
+ lengthEquals: typeof import("vest-utils").lengthEquals;
84
79
  lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
85
80
  lessThan: typeof lessThan;
86
81
  lessThanOrEquals: typeof lessThanOrEquals;
87
- longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
82
+ longerThan: typeof import("vest-utils").longerThan;
88
83
  longerThanOrEquals: typeof longerThanOrEquals;
89
84
  lt: typeof lessThan;
90
85
  lte: typeof lessThanOrEquals;
@@ -92,13 +87,13 @@ declare const baseRules: {
92
87
  notEquals: (value: unknown, arg1: unknown) => boolean;
93
88
  notInside: (value: unknown, arg1: string | unknown[]) => boolean;
94
89
  notMatches: (value: string, regex: string | RegExp) => boolean;
95
- numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
90
+ numberEquals: typeof import("vest-utils").numberEquals;
96
91
  numberNotEquals: (value: string | number, eq: string | number) => boolean;
97
92
  shorterThan: typeof shorterThan;
98
93
  shorterThanOrEquals: typeof shorterThanOrEquals;
99
94
  startsWith: typeof startsWith;
100
95
  };
101
- type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
96
+ type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
102
97
  [P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
103
98
  };
104
99
  /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
@@ -121,6 +116,10 @@ type LazyRuleRunners = {
121
116
  run: (value: unknown) => RuleDetailedResult;
122
117
  };
123
118
  type ComposeResult = LazyRuleRunners & ((value: any) => void);
124
- type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
119
+ type LazyMessage = DynamicValue<string, [
120
+ value: unknown,
121
+ originalMessage?: Stringable
122
+ ]>;
125
123
  declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
126
124
  export { compose as default };
125
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/exports/compose.ts","../src/runtime/enforceContext.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,iBAAwB,OAAO,CAC7B,GAAG,UAAU,EAAE,eAAe,EAAE,GAC/B,aAAa,CAoCf"}
@@ -1,9 +1,4 @@
1
- type DropFirst<T extends unknown[]> = T extends [
2
- unknown,
3
- ...infer U
4
- ] ? U : never;
5
- type Stringable = string | ((...args: any[]) => string);
6
- type CB = (...args: any[]) => any;
1
+ import { CB, DropFirst, Stringable, DynamicValue, BlankValue } from "vest-utils";
7
2
  type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
8
3
  type RuleReturn = boolean | {
9
4
  pass: boolean;
@@ -22,7 +17,7 @@ declare function equals(value: unknown, arg1: unknown): boolean;
22
17
  declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
23
18
  declare function inside(value: unknown, arg1: string | unknown[]): boolean;
24
19
  declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
25
- declare function isBlank(value: unknown): boolean;
20
+ declare function isBlank(value: unknown): value is BlankValue;
26
21
  declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
27
22
  declare function isNaN(value: unknown): boolean;
28
23
  declare function isNegative(value: number | string): boolean;
@@ -42,16 +37,16 @@ declare const baseRules: {
42
37
  doesNotStartWith: (value: string, arg1: string) => boolean;
43
38
  endsWith: typeof endsWith;
44
39
  equals: typeof equals;
45
- greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
40
+ greaterThan: typeof import("vest-utils").greaterThan;
46
41
  greaterThanOrEquals: typeof greaterThanOrEquals;
47
- gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
42
+ gt: typeof import("vest-utils").greaterThan;
48
43
  gte: typeof greaterThanOrEquals;
49
44
  inside: typeof inside;
50
- isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
45
+ isArray: typeof import("vest-utils").isArray;
51
46
  isBetween: typeof isBetween;
52
47
  isBlank: typeof isBlank;
53
- isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
54
- isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
48
+ isBoolean: typeof import("vest-utils").isBoolean;
49
+ isEmpty: typeof import("vest-utils").isEmpty;
55
50
  isEven: (value: any) => boolean;
56
51
  isFalsy: (value: unknown) => boolean;
57
52
  isKeyOf: typeof isKeyOf;
@@ -71,21 +66,21 @@ declare const baseRules: {
71
66
  isNotString: (v: unknown) => boolean;
72
67
  isNotUndefined: (value?: unknown) => boolean;
73
68
  isNotValueOf: (value: any, objectToCheck: any) => boolean;
74
- isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
75
- isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
69
+ isNull: typeof import("vest-utils").isNull;
70
+ isNullish: typeof import("vest-utils").isNullish;
76
71
  isNumber: typeof isNumber;
77
- isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
72
+ isNumeric: typeof import("vest-utils").isNumeric;
78
73
  isOdd: (value: any) => boolean;
79
- isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
80
- isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
74
+ isPositive: typeof import("vest-utils").isPositive;
75
+ isString: typeof import("vest-utils").isStringValue;
81
76
  isTruthy: typeof isTruthy;
82
- isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
77
+ isUndefined: typeof import("vest-utils").isUndefined;
83
78
  isValueOf: typeof isValueOf;
84
- lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
79
+ lengthEquals: typeof import("vest-utils").lengthEquals;
85
80
  lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
86
81
  lessThan: typeof lessThan;
87
82
  lessThanOrEquals: typeof lessThanOrEquals;
88
- longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
83
+ longerThan: typeof import("vest-utils").longerThan;
89
84
  longerThanOrEquals: typeof longerThanOrEquals;
90
85
  lt: typeof lessThan;
91
86
  lte: typeof lessThanOrEquals;
@@ -93,13 +88,13 @@ declare const baseRules: {
93
88
  notEquals: (value: unknown, arg1: unknown) => boolean;
94
89
  notInside: (value: unknown, arg1: string | unknown[]) => boolean;
95
90
  notMatches: (value: string, regex: string | RegExp) => boolean;
96
- numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
91
+ numberEquals: typeof import("vest-utils").numberEquals;
97
92
  numberNotEquals: (value: string | number, eq: string | number) => boolean;
98
93
  shorterThan: typeof shorterThan;
99
94
  shorterThanOrEquals: typeof shorterThanOrEquals;
100
95
  startsWith: typeof startsWith;
101
96
  };
102
- type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
97
+ type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
103
98
  [P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
104
99
  };
105
100
  /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
@@ -121,7 +116,10 @@ type LazyRuleRunners = {
121
116
  test: (value: unknown) => boolean;
122
117
  run: (value: unknown) => RuleDetailedResult;
123
118
  };
124
- type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
119
+ type LazyMessage = DynamicValue<string, [
120
+ value: unknown,
121
+ originalMessage?: Stringable
122
+ ]>;
125
123
  type EnforceCompoundRule = (value: unknown, ...rules: Lazy[]) => RuleDetailedResult;
126
124
  declare global {
127
125
  namespace n4s {
@@ -133,4 +131,4 @@ declare global {
133
131
  }
134
132
  }
135
133
  }
136
- export {};
134
+ //# sourceMappingURL=compounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../src/exports/compounds.ts","../src/runtime/enforceContext.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts","../src/plugins/compounds/allOf.ts","../src/plugins/compounds/anyOf.ts","../src/lib/enforceUtilityTypes.ts","../src/plugins/compounds/noneOf.ts","../src/plugins/compounds/oneOf.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,KAAK,EAAE,IAAI,EAAE,KACb,kBAAkB,CAAC;AAGxB,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,MAAM,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACrD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;SACrD;KACF;CACF"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="validator" />
2
+ import isAfter from 'validator/es/lib/isAfter';
3
+ import isBefore from 'validator/es/lib/isBefore';
4
+ import isDate from 'validator/es/lib/isDate';
5
+ import isISO8601 from 'validator/es/lib/isISO8601';
6
+ import { CB, DropFirst } from "vest-utils";
7
+ type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
8
+ declare global {
9
+ namespace n4s {
10
+ interface EnforceCustomMatchers<R> {
11
+ isAfter: EnforceCustomMatcher<typeof isAfter, R>;
12
+ isBefore: EnforceCustomMatcher<typeof isBefore, R>;
13
+ isDate: EnforceCustomMatcher<typeof isDate, R>;
14
+ isISO8601: EnforceCustomMatcher<typeof isISO8601, R>;
15
+ }
16
+ }
17
+ }
18
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/exports/date.ts","../src/lib/enforceUtilityTypes.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,SAAS,MAAM,4BAA4B,CAAC;;;AAOnD,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,OAAO,EAAE,oBAAoB,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC;YACjD,QAAQ,EAAE,oBAAoB,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnD,MAAM,EAAE,oBAAoB,CAAC,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC;YAC/C,SAAS,EAAE,oBAAoB,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC;SACtD;KACF;CACF"}