vest 4.4.2 → 4.4.3-dev-c786f7
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.
- package/dist/cjs/classnames.development.js +9 -60
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -58
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +8 -51
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +5 -57
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +8 -59
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +2 -26
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +119 -368
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +1 -52
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -54
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -45
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +1 -53
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +1 -52
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +1 -25
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +44 -293
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +11 -11
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +94 -94
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +117 -117
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +117 -117
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +11 -11
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +296 -295
- package/dist/umd/vest.production.js +1 -1
- package/package.json +4 -3
- package/testUtils/__tests__/partition.test.ts +21 -0
- package/testUtils/mockThrowError.ts +2 -1
- package/testUtils/partition.ts +13 -0
- package/testUtils/suiteDummy.ts +1 -1
- package/types/enforce/compose.d.ts +15 -31
- package/types/enforce/compounds.d.ts +15 -31
- package/types/enforce/schema.d.ts +15 -31
- package/types/vest.d.ts +1 -1
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var assign = Object.assign;
|
|
8
|
-
|
|
9
|
-
function isFunction(value) {
|
|
10
|
-
return typeof value === 'function';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
function bindNot(fn) {
|
|
14
8
|
return function () {
|
|
15
9
|
var args = [];
|
|
@@ -20,6 +14,32 @@
|
|
|
20
14
|
};
|
|
21
15
|
}
|
|
22
16
|
|
|
17
|
+
function isNumeric(value) {
|
|
18
|
+
var str = String(value);
|
|
19
|
+
var num = Number(value);
|
|
20
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
21
|
+
return Boolean(result);
|
|
22
|
+
}
|
|
23
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
24
|
+
|
|
25
|
+
function numberEquals(value, eq) {
|
|
26
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
27
|
+
}
|
|
28
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
29
|
+
|
|
30
|
+
function lengthEquals(value, arg1) {
|
|
31
|
+
return numberEquals(value.length, arg1);
|
|
32
|
+
}
|
|
33
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
34
|
+
|
|
35
|
+
function greaterThan(value, gt) {
|
|
36
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function longerThan(value, arg1) {
|
|
40
|
+
return greaterThan(value.length, arg1);
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
function isNull(value) {
|
|
24
44
|
return value === null;
|
|
25
45
|
}
|
|
@@ -35,49 +55,115 @@
|
|
|
35
55
|
}
|
|
36
56
|
var isNotNullish = bindNot(isNullish);
|
|
37
57
|
|
|
58
|
+
function isFunction(value) {
|
|
59
|
+
return typeof value === 'function';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function optionalFunctionValue(value) {
|
|
63
|
+
var args = [];
|
|
64
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
65
|
+
args[_i - 1] = arguments[_i];
|
|
66
|
+
}
|
|
67
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function defaultTo(value, defaultValue) {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The module is named "isArrayValue" since it
|
|
76
|
+
// is conflicting with a nested npm dependency.
|
|
77
|
+
// We may need to revisit this in the future.
|
|
78
|
+
function isArray(value) {
|
|
79
|
+
return Boolean(Array.isArray(value));
|
|
80
|
+
}
|
|
81
|
+
var isNotArray = bindNot(isArray);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A safe hasOwnProperty access
|
|
85
|
+
*/
|
|
86
|
+
function hasOwnProperty(obj, key) {
|
|
87
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var assign = Object.assign;
|
|
91
|
+
|
|
92
|
+
function invariant(condition,
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
94
|
+
message) {
|
|
95
|
+
if (condition) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// If message is a string object (rather than string literal)
|
|
99
|
+
// Throw the value directly as a string
|
|
100
|
+
// Alternatively, throw an error with the message
|
|
101
|
+
throw message instanceof String
|
|
102
|
+
? message.valueOf()
|
|
103
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
104
|
+
}
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
106
|
+
function StringObject(value) {
|
|
107
|
+
return new String(optionalFunctionValue(value));
|
|
108
|
+
}
|
|
109
|
+
|
|
38
110
|
function isStringValue(v) {
|
|
39
111
|
return String(v) === v;
|
|
40
112
|
}
|
|
41
113
|
|
|
42
|
-
function
|
|
43
|
-
return
|
|
114
|
+
function isBoolean(value) {
|
|
115
|
+
return !!value === value;
|
|
44
116
|
}
|
|
45
|
-
var doesNotEndWith = bindNot(endsWith);
|
|
46
117
|
|
|
47
|
-
function
|
|
48
|
-
|
|
118
|
+
function mapFirst(array, callback) {
|
|
119
|
+
var broke = false;
|
|
120
|
+
var breakoutValue = null;
|
|
121
|
+
for (var i = 0; i < array.length; i++) {
|
|
122
|
+
callback(array[i], breakout, i);
|
|
123
|
+
if (broke) {
|
|
124
|
+
return breakoutValue;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function breakout(conditional, value) {
|
|
128
|
+
if (conditional) {
|
|
129
|
+
broke = true;
|
|
130
|
+
breakoutValue = value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
49
133
|
}
|
|
50
|
-
var notEquals = bindNot(equals);
|
|
51
134
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
135
|
+
function isEmpty(value) {
|
|
136
|
+
if (!value) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
140
|
+
return lengthEquals(value, 0);
|
|
141
|
+
}
|
|
142
|
+
else if (typeof value === 'object') {
|
|
143
|
+
return lengthEquals(Object.keys(value), 0);
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
57
146
|
}
|
|
58
|
-
var
|
|
147
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
59
148
|
|
|
60
|
-
function
|
|
61
|
-
return
|
|
149
|
+
function isPositive(value) {
|
|
150
|
+
return greaterThan(value, 0);
|
|
62
151
|
}
|
|
63
152
|
|
|
64
|
-
function
|
|
65
|
-
return
|
|
153
|
+
function endsWith(value, arg1) {
|
|
154
|
+
return isStringValue(value) && isStringValue(arg1) && value.endsWith(arg1);
|
|
66
155
|
}
|
|
67
|
-
var
|
|
156
|
+
var doesNotEndWith = bindNot(endsWith);
|
|
157
|
+
|
|
158
|
+
function equals(value, arg1) {
|
|
159
|
+
return value === arg1;
|
|
160
|
+
}
|
|
161
|
+
var notEquals = bindNot(equals);
|
|
68
162
|
|
|
69
163
|
function greaterThanOrEquals(value, gte) {
|
|
70
164
|
return numberEquals(value, gte) || greaterThan(value, gte);
|
|
71
165
|
}
|
|
72
166
|
|
|
73
|
-
// The module is named "isArrayValue" since it
|
|
74
|
-
// is conflicting with a nested npm dependency.
|
|
75
|
-
// We may need to revisit this in the future.
|
|
76
|
-
function isArray(value) {
|
|
77
|
-
return Boolean(Array.isArray(value));
|
|
78
|
-
}
|
|
79
|
-
var isNotArray = bindNot(isArray);
|
|
80
|
-
|
|
81
167
|
function inside(value, arg1) {
|
|
82
168
|
if (isArray(arg1)) {
|
|
83
169
|
return arg1.indexOf(value) !== -1;
|
|
@@ -108,38 +194,8 @@
|
|
|
108
194
|
}
|
|
109
195
|
var isNotBlank = bindNot(isBlank);
|
|
110
196
|
|
|
111
|
-
function isBoolean(value) {
|
|
112
|
-
return !!value === value;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
197
|
var isNotBoolean = bindNot(isBoolean);
|
|
116
198
|
|
|
117
|
-
/**
|
|
118
|
-
* A safe hasOwnProperty access
|
|
119
|
-
*/
|
|
120
|
-
function hasOwnProperty(obj, key) {
|
|
121
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function lengthEquals(value, arg1) {
|
|
125
|
-
return numberEquals(value.length, arg1);
|
|
126
|
-
}
|
|
127
|
-
var lengthNotEquals = bindNot(lengthEquals);
|
|
128
|
-
|
|
129
|
-
function isEmpty(value) {
|
|
130
|
-
if (!value) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
134
|
-
return lengthEquals(value, 0);
|
|
135
|
-
}
|
|
136
|
-
else if (typeof value === 'object') {
|
|
137
|
-
return lengthEquals(Object.keys(value), 0);
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
142
|
-
|
|
143
199
|
/**
|
|
144
200
|
* Validates that a given value is an even number
|
|
145
201
|
*/
|
|
@@ -179,10 +235,6 @@
|
|
|
179
235
|
return false;
|
|
180
236
|
};
|
|
181
237
|
|
|
182
|
-
function isPositive(value) {
|
|
183
|
-
return greaterThan(value, 0);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
238
|
var isNotString = bindNot(isStringValue);
|
|
187
239
|
|
|
188
240
|
function isTruthy(value) {
|
|
@@ -203,10 +255,6 @@
|
|
|
203
255
|
}
|
|
204
256
|
var isNotValueOf = bindNot(isValueOf);
|
|
205
257
|
|
|
206
|
-
function longerThan(value, arg1) {
|
|
207
|
-
return greaterThan(value.length, arg1);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
258
|
function longerThanOrEquals(value, arg1) {
|
|
211
259
|
return greaterThanOrEquals(value.length, arg1);
|
|
212
260
|
}
|
|
@@ -327,37 +375,6 @@
|
|
|
327
375
|
}
|
|
328
376
|
}
|
|
329
377
|
|
|
330
|
-
function optionalFunctionValue(value) {
|
|
331
|
-
var args = [];
|
|
332
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
333
|
-
args[_i - 1] = arguments[_i];
|
|
334
|
-
}
|
|
335
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function defaultTo(value, defaultValue) {
|
|
339
|
-
var _a;
|
|
340
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function invariant(condition,
|
|
344
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
345
|
-
message) {
|
|
346
|
-
if (condition) {
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
// If message is a string object (rather than string literal)
|
|
350
|
-
// Throw the value directly as a string
|
|
351
|
-
// Alternatively, throw an error with the message
|
|
352
|
-
throw message instanceof String
|
|
353
|
-
? message.valueOf()
|
|
354
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
355
|
-
}
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
357
|
-
function StringObject(value) {
|
|
358
|
-
return new String(optionalFunctionValue(value));
|
|
359
|
-
}
|
|
360
|
-
|
|
361
378
|
// eslint-disable-next-line max-lines-per-function
|
|
362
379
|
function createContext(init) {
|
|
363
380
|
var storage = { ancestry: [] };
|
|
@@ -547,23 +564,6 @@
|
|
|
547
564
|
}
|
|
548
565
|
}
|
|
549
566
|
|
|
550
|
-
function mapFirst(array, callback) {
|
|
551
|
-
var broke = false;
|
|
552
|
-
var breakoutValue = null;
|
|
553
|
-
for (var i = 0; i < array.length; i++) {
|
|
554
|
-
callback(array[i], breakout, i);
|
|
555
|
-
if (broke) {
|
|
556
|
-
return breakoutValue;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
function breakout(conditional, value) {
|
|
560
|
-
if (conditional) {
|
|
561
|
-
broke = true;
|
|
562
|
-
breakoutValue = value;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
567
|
// eslint-disable-next-line max-lines-per-function
|
|
568
568
|
function genEnforceLazy(key) {
|
|
569
569
|
var registeredRules = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).schema={})}(this,(function(n){function t(n){return
|
|
1
|
+
"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).schema={})}(this,(function(n){function t(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function r(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function e(n,t){return r(n)&&r(t)&&Number(n)===Number(t)}function u(n,t){return e(n.length,t)}function i(n,t){return r(n)&&r(t)&&Number(n)>Number(t)}function o(n){return null===n}function a(n){return void 0===n}function f(n){return null===n||a(n)}function s(n){return"function"==typeof n}function c(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return s(n)?n.apply(void 0,t):n}function l(n,t){var r;return null!==(r=c(n))&&void 0!==r?r:c(t)}function p(n){return!!Array.isArray(n)}function v(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?c(t):t)}function h(n){return String(n)===n}function y(n){return!!n===n}function N(n,t){function r(n,t){n&&(e=!0,u=t)}for(var e=!1,u=null,i=0;i<n.length;i++)if(t(n[i],r,i),e)return u}function d(n){return!n||(Object.prototype.hasOwnProperty.call(n,"length")?u(n,0):"object"==typeof n&&u(Object.keys(n),0))}function g(n,t){return h(n)&&h(t)&&n.endsWith(t)}function m(n,t){return n===t}function b(n,t){return e(n,t)||i(n,t)}function O(n,t){return!!(p(t)||h(t)&&h(n))&&-1!==t.indexOf(n)}function x(n,t){return r(n)&&r(t)&&Number(n)<Number(t)}function E(n,t){return e(n,t)||x(n,t)}function w(n,t,r){return b(n,t)&&E(n,r)}function T(n){return f(n)||h(n)&&!n.trim()}function q(n,t){return n in t}function j(n){return Number.isNaN(n)}function S(n){return"number"==typeof n}function P(n){return!!n}function A(n,t){if(f(t))return!1;for(var r in t)if(t[r]===n)return!0;return!1}function B(n,t){return t instanceof RegExp?t.test(n):!!h(t)&&new RegExp(t).test(n)}function W(n,t){return h(n)&&h(t)&&n.startsWith(t)}function k(n){for(var t in pn){var r=pn[t];s(r)&&n(t,r)}}function F(){return null}function I(n,t,r){if(r||2===arguments.length)for(var e,u=0,i=t.length;u<i;u++)!e&&u in t||(e||(e=Array.prototype.slice.call(t,0,u)),e[u]=t[u]);return n.concat(e||Array.prototype.slice.call(t))}function J(){try{return s(Proxy)}catch(n){return!1}}function K(n,t){return n={pass:n},t&&(n.message=t),n}function M(n,t,r){for(var e=[],u=3;u<arguments.length;u++)e[u-3]=arguments[u];return v(y(n)||n&&y(n.pass),"Incorrect return value for rule: "+JSON.stringify(n)),y(n)?K(n):K(n.pass,c.apply(void 0,I([n.message,t,r],e,!1)))}function R(n){function t(t,r,e){return function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];return v((i=vn.run({value:n},(function(){return M.apply(void 0,I([r.apply(void 0,I([n],u,!1)),e,n],u,!1))}))).pass,f(i.message)?"enforce/".concat(e," failed with ").concat(JSON.stringify(n)):new String(c(i.message))),t}}var r={};if(!J())return k((function(n,e){r[n]=t(r,e,n)})),r;var e=new Proxy(r,{get:function(n,r){if(n=pn[r])return t(e,n,r)}});return e}function U(n){var t,r=[];return function n(e){return function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];var o=pn[e];r.push((function(n){return M.apply(void 0,I([o.apply(void 0,I([n],u,!1)),e,n],u,!1))}));var a={run:function(n){return l(N(r,(function(r,e){var u,i=vn.run({value:n},(function(){return r(n)}));e(!i.pass,K(!!i.pass,null!==(u=c(t,n,i.message))&&void 0!==u?u:i.message))})),K(!0))},test:function(n){return a.run(n).pass},message:function(n){return n&&(t=n),a}};return J()?a=new Proxy(a,{get:function(t,r){return pn[r]?n(r):t[r]}}):(k((function(t){a[t]=n(t)})),a)}}(n)}function V(n,t){try{return n.run(t)}catch(n){return K(!1)}}function X(n,t){var r,e=function(r){var e=n[r],u=t[r];if(!(r=vn.run({value:e,set:!0,meta:{key:r}},(function(){return V(u,e)}))).pass)return{value:r}};for(r in t){var u=e(r);if("object"==typeof u)return u.value}return K(!0)}var _=t(r),z=t(e),C=t(u),D=t(o),G=t(a),H=t(f),L=t(p),Q=Object.assign,Y=t(d),Z=t(g),$=t(m),nn=t(O),tn=t(w),rn=t(T),en=t(y),un=t(q),on=t(j),an=t(S),fn=t(h),sn=t(P),cn=t(A),ln=t(B),pn={condition:function(n,t){try{return t(n)}catch(n){return!1}},doesNotEndWith:Z,doesNotStartWith:t(W),endsWith:g,equals:m,greaterThan:i,greaterThanOrEquals:b,gt:i,gte:b,inside:O,isArray:p,isBetween:w,isBlank:T,isBoolean:y,isEmpty:d,isEven:function(n){return!!r(n)&&0==n%2},isFalsy:sn,isKeyOf:q,isNaN:j,isNegative:function(n){return x(n,0)},isNotArray:L,isNotBetween:tn,isNotBlank:rn,isNotBoolean:en,isNotEmpty:Y,isNotKeyOf:un,isNotNaN:on,isNotNull:D,isNotNullish:H,isNotNumber:an,isNotNumeric:_,isNotString:fn,isNotUndefined:G,isNotValueOf:cn,isNull:o,isNullish:f,isNumber:S,isNumeric:r,isOdd:function(n){return!!r(n)&&0!=n%2},isPositive:function(n){return i(n,0)},isString:h,isTruthy:P,isUndefined:a,isValueOf:A,lengthEquals:u,lengthNotEquals:C,lessThan:x,lessThanOrEquals:E,longerThan:function(n,t){return i(n.length,t)},longerThanOrEquals:function(n,t){return b(n.length,t)},lt:x,lte:E,matches:B,notEquals:$,notInside:nn,notMatches:ln,numberEquals:e,numberNotEquals:z,shorterThan:function(n,t){return x(n.length,t)},shorterThanOrEquals:function(n,t){return E(n.length,t)},startsWith:W},vn=function(n){function t(t,u){var i,o,a=r();return t=Q({},a||{},null!==(i=c(n,t,a))&&void 0!==i?i:t),i=e.ctx=Object.freeze(t),e.ancestry.unshift(i),u=u(i),e.ancestry.shift(),e.ctx=null!==(o=e.ancestry[0])&&void 0!==o?o:null,u}function r(){return e.ctx}var e={ancestry:[]};return{bind:function(n,r){return function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];return t(n,(function(){return r.apply(void 0,e)}))}},run:t,use:r,useX:function(n){var t=r();return v(t,l(n,"Context was used after it was closed")),t}}}((function(n,t){var r={value:n.value,meta:n.meta||{}};return t?n.set?Q(r,{parent:function(){return t?{value:t.value,meta:t.meta,parent:t.parent}:t}}):t:Q(r,{parent:F})})),hn=function(){function n(){if(!J())return k((function(n){t[n]=U(n)})),Q(R,t)}var t={context:function(){return vn.useX()},extend:function(t){Q(pn,t),n()}};return n(),new Proxy(Q(R,t),{get:function(n,t){return t in n?n[t]:pn[t]?U(t):void 0}})}();hn.extend({isArrayOf:function(n,t){return l(N(n,(function(n,r,e){r(!(e=vn.run({value:n,set:!0,meta:{index:e}},(function(){return V(t,n)}))).pass,e)})),K(!0))},loose:X,optional:function(n,t){return f(n)?K(!0):V(t,n)},shape:function(n,t){var r=X(n,t);if(!r.pass)return r;for(var e in n)if(!Object.prototype.hasOwnProperty.call(t,e))return K(!1);return K(!0)}}),n.partial=function(n){var t,r={};for(t in n)r[t]=hn.optional(n[t]);return r},Object.defineProperty(n,"__esModule",{value:!0})}));
|
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function isNumeric(value) {
|
|
8
|
+
var str = String(value);
|
|
9
|
+
var num = Number(value);
|
|
10
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
11
|
+
return Boolean(result);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function greaterThan(value, gt) {
|
|
15
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
function isFunction(value) {
|
|
8
19
|
return typeof value === 'function';
|
|
9
20
|
}
|
|
@@ -42,17 +53,6 @@
|
|
|
42
53
|
: new Error(message ? optionalFunctionValue(message) : message);
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
function isNumeric(value) {
|
|
46
|
-
var str = String(value);
|
|
47
|
-
var num = Number(value);
|
|
48
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
49
|
-
return Boolean(result);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function greaterThan(value, gt) {
|
|
53
|
-
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
56
|
function isPositive(value) {
|
|
57
57
|
return greaterThan(value, 0);
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).parser={})}(this,(function(t){function e(t){
|
|
1
|
+
"use strict";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).parser={})}(this,(function(t){function e(t){var e=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(e))}function n(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return"function"==typeof t?t.apply(void 0,e):t}var o,i,u;(i=o||(o={})).WARNINGS="warnings",i.ERRORS="errors",function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(u||(u={})),t.parse=function(t){function e(e,o){var i,u;return e=o?null===(i=t.tests[o])||void 0===i?void 0:i[e]:t[e],n(i=null!==(u=r(e))&&void 0!==u?u:r(0),0)}!function(t,e){if(!t)throw e instanceof String?e.valueOf():Error(e?r(e):e)}(t&&Object.prototype.hasOwnProperty.call(t,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var o={},i={invalid:function(t){return e(u.ERROR_COUNT,t)},tested:function(e){return e?Object.prototype.hasOwnProperty.call(o,e)?o[e]:(o[e]=Object.prototype.hasOwnProperty.call(t.tests,e)&&n(t.tests[e].testCount,0),i.tested(e)):n(t.testCount,0)},untested:function(e){return 0===t.testCount||!i.tested(e)},valid:function(e){var n;return e?!(null===(n=t.tests[e])||void 0===n||!n.valid):t.valid},warning:function(t){return e(u.WARN_COUNT,t)}};return i},Object.defineProperty(t,"__esModule",{value:!0})}));
|