vest 4.2.3-dev-87ebfa → 4.3.2-dev-2805e3
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 +61 -23
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +20 -5
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +1 -1
- package/dist/cjs/parser.development.js +87 -22
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/vest.development.js +548 -566
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +61 -23
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -1
- package/dist/es/enforce/compounds.development.js +20 -5
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +1 -1
- package/dist/es/parser.development.js +87 -22
- package/dist/es/parser.production.js +1 -1
- package/dist/es/vest.development.js +548 -566
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +61 -23
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +34 -30
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +36 -32
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +34 -30
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +87 -22
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +482 -515
- package/dist/umd/vest.production.js +1 -1
- package/package.json +1 -1
- package/testUtils/suiteDummy.ts +5 -1
- package/types/classnames.d.ts +17 -55
- package/types/enforce/compose.d.ts +22 -21
- package/types/enforce/compounds.d.ts +24 -23
- package/types/enforce/schema.d.ts +26 -25
- package/types/parser.d.ts +16 -54
- package/types/promisify.d.ts +23 -16
- package/types/vest.d.ts +109 -101
|
@@ -76,8 +76,13 @@
|
|
|
76
76
|
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
function numberEquals(value, eq) {
|
|
80
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
81
|
+
}
|
|
82
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
83
|
+
|
|
79
84
|
function greaterThanOrEquals(value, gte) {
|
|
80
|
-
return
|
|
85
|
+
return numberEquals(value, gte) || greaterThan(value, gte);
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
// The module is named "isArrayValue" since it
|
|
@@ -100,8 +105,12 @@
|
|
|
100
105
|
}
|
|
101
106
|
var notInside = bindNot(inside);
|
|
102
107
|
|
|
108
|
+
function lessThan(value, lt) {
|
|
109
|
+
return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
|
|
110
|
+
}
|
|
111
|
+
|
|
103
112
|
function lessThanOrEquals(value, lte) {
|
|
104
|
-
return
|
|
113
|
+
return numberEquals(value, lte) || lessThan(value, lte);
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
function isBetween(value, min, max) {
|
|
@@ -133,7 +142,7 @@
|
|
|
133
142
|
var isNotNumber = bindNot(isNumber);
|
|
134
143
|
|
|
135
144
|
function lengthEquals(value, arg1) {
|
|
136
|
-
return value.length
|
|
145
|
+
return numberEquals(value.length, arg1);
|
|
137
146
|
}
|
|
138
147
|
var lengthNotEquals = bindNot(lengthEquals);
|
|
139
148
|
|
|
@@ -150,7 +159,7 @@
|
|
|
150
159
|
else if (typeof value === 'object') {
|
|
151
160
|
return lengthEquals(Object.keys(value), 0);
|
|
152
161
|
}
|
|
153
|
-
return
|
|
162
|
+
return false;
|
|
154
163
|
}
|
|
155
164
|
var isNotEmpty = bindNot(isEmpty);
|
|
156
165
|
|
|
@@ -175,12 +184,8 @@
|
|
|
175
184
|
var isNotNaN = bindNot(isNaN$1);
|
|
176
185
|
|
|
177
186
|
function isNegative(value) {
|
|
178
|
-
|
|
179
|
-
return Number(value) < 0;
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
187
|
+
return lessThan(value, 0);
|
|
182
188
|
}
|
|
183
|
-
var isPositive = bindNot(isNegative);
|
|
184
189
|
|
|
185
190
|
/**
|
|
186
191
|
* Validates that a given value is an odd number
|
|
@@ -192,6 +197,10 @@
|
|
|
192
197
|
return false;
|
|
193
198
|
};
|
|
194
199
|
|
|
200
|
+
function isPositive(value) {
|
|
201
|
+
return greaterThan(value, 0);
|
|
202
|
+
}
|
|
203
|
+
|
|
195
204
|
var isNotString = bindNot(isStringValue);
|
|
196
205
|
|
|
197
206
|
function isTruthy(value) {
|
|
@@ -212,16 +221,12 @@
|
|
|
212
221
|
}
|
|
213
222
|
var isNotValueOf = bindNot(isValueOf);
|
|
214
223
|
|
|
215
|
-
function lessThan(value, lt) {
|
|
216
|
-
return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
224
|
function longerThan(value, arg1) {
|
|
220
|
-
return value.length
|
|
225
|
+
return greaterThan(value.length, arg1);
|
|
221
226
|
}
|
|
222
227
|
|
|
223
228
|
function longerThanOrEquals(value, arg1) {
|
|
224
|
-
return value.length
|
|
229
|
+
return greaterThanOrEquals(value.length, arg1);
|
|
225
230
|
}
|
|
226
231
|
|
|
227
232
|
function matches(value, regex) {
|
|
@@ -237,11 +242,6 @@
|
|
|
237
242
|
}
|
|
238
243
|
var notMatches = bindNot(matches);
|
|
239
244
|
|
|
240
|
-
function numberEquals(value, eq) {
|
|
241
|
-
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
242
|
-
}
|
|
243
|
-
var numberNotEquals = bindNot(numberEquals);
|
|
244
|
-
|
|
245
245
|
function condition(value, callback) {
|
|
246
246
|
try {
|
|
247
247
|
return callback(value);
|
|
@@ -252,11 +252,11 @@
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
function shorterThan(value, arg1) {
|
|
255
|
-
return value.length
|
|
255
|
+
return lessThan(value.length, arg1);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
function shorterThanOrEquals(value, arg1) {
|
|
259
|
-
return value.length
|
|
259
|
+
return lessThanOrEquals(value.length, arg1);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
function startsWith(value, arg1) {
|
|
@@ -647,15 +647,10 @@
|
|
|
647
647
|
context: function () { return ctx.useX(); },
|
|
648
648
|
extend: function (customRules) {
|
|
649
649
|
assign(baseRules, customRules);
|
|
650
|
+
handleNoProxy(); // TODO: REMOVE when we stop supporting ES5
|
|
650
651
|
}
|
|
651
652
|
};
|
|
652
|
-
|
|
653
|
-
eachEnforceRule(function (ruleName) {
|
|
654
|
-
// Only on the first rule access - start the chain of calls
|
|
655
|
-
target[ruleName] = genEnforceLazy(ruleName);
|
|
656
|
-
});
|
|
657
|
-
return assign(enforceEager, target);
|
|
658
|
-
}
|
|
653
|
+
handleNoProxy();
|
|
659
654
|
return new Proxy(assign(enforceEager, target), {
|
|
660
655
|
get: function (target, key) {
|
|
661
656
|
if (key in target) {
|
|
@@ -668,6 +663,15 @@
|
|
|
668
663
|
return genEnforceLazy(key);
|
|
669
664
|
}
|
|
670
665
|
});
|
|
666
|
+
function handleNoProxy() {
|
|
667
|
+
if (!isProxySupported()) {
|
|
668
|
+
eachEnforceRule(function (ruleName) {
|
|
669
|
+
// Only on the first rule access - start the chain of calls
|
|
670
|
+
target[ruleName] = genEnforceLazy(ruleName);
|
|
671
|
+
});
|
|
672
|
+
return assign(enforceEager, target);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
671
675
|
}
|
|
672
676
|
var enforce = genEnforce();
|
|
673
677
|
|
|
@@ -729,7 +733,7 @@
|
|
|
729
733
|
}
|
|
730
734
|
|
|
731
735
|
// Help needed improving the typings of this file.
|
|
732
|
-
// Ideally, we'd be able to extend
|
|
736
|
+
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
733
737
|
function partial(shapeObject) {
|
|
734
738
|
var output = {};
|
|
735
739
|
for (var key in shapeObject) {
|
|
@@ -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,t){function r(n){e=!0,u=n}for(var e=!1,u=null,i=0;i<n.length;i++)if(t(n[i],r,i),e)return u}function r(n){return"function"==typeof n}function e(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function u(n){return null===n}function i(n){return void 0===n}function o(n){return null===n||i(n)}function a(n){return String(n)===n}function f(n,t){return a(n)&&a(t)&&n.endsWith(t)}function s(n,t){return n===t}function c(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function l(n,t){return c(n)&&c(t)&&Number(n)>Number(t)}function p(n,t){return c(n)&&c(t)&&Number(n)
|
|
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,t){function r(n){e=!0,u=n}for(var e=!1,u=null,i=0;i<n.length;i++)if(t(n[i],r,i),e)return u}function r(n){return"function"==typeof n}function e(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function u(n){return null===n}function i(n){return void 0===n}function o(n){return null===n||i(n)}function a(n){return String(n)===n}function f(n,t){return a(n)&&a(t)&&n.endsWith(t)}function s(n,t){return n===t}function c(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function l(n,t){return c(n)&&c(t)&&Number(n)>Number(t)}function p(n,t){return c(n)&&c(t)&&Number(n)===Number(t)}function v(n,t){return p(n,t)||l(n,t)}function h(n){return!!Array.isArray(n)}function y(n,t){return!!(h(t)||a(t)&&a(n))&&-1!==t.indexOf(n)}function N(n,t){return c(n)&&c(t)&&Number(n)<Number(t)}function d(n,t){return p(n,t)||N(n,t)}function g(n,t,r){return v(n,t)&&d(n,r)}function m(n){return o(n)||a(n)&&!n.trim()}function b(n){return!!n===n}function O(n){return"number"==typeof n}function x(n,t){return p(n.length,t)}function E(n){return!n||(O(n)?0===n:Object.prototype.hasOwnProperty.call(n,"length")?x(n,0):"object"==typeof n&&x(Object.keys(n),0))}function w(n,t){return n in t}function T(n){return Number.isNaN(n)}function q(n){return!!n}function j(n,t){if(o(t))return!1;for(var r in t)if(t[r]===n)return!0;return!1}function S(n,t){return t instanceof RegExp?t.test(n):!!a(t)&&new RegExp(t).test(n)}function P(n,t){return a(n)&&a(t)&&n.startsWith(t)}function A(n){for(var t in pn){var e=pn[t];r(e)&&n(t,e)}}function B(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return r(n)?n.apply(void 0,t):n}function W(n,t){var r;return null!==(r=B(n))&&void 0!==r?r:t}function k(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?B(t):t)}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 r(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 k(b(n)||n&&b(n.pass),"Incorrect return value for rule: "+JSON.stringify(n)),b(n)?K(n):K(n.pass,B.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 k((i=M.apply(void 0,I([vn.run({value:n},(function(){return r.apply(void 0,I([n],u,!1))})),e,n],u,!1))).pass,E(i.message)?"enforce/".concat(e," failed with ").concat(JSON.stringify(n)):new String(i.message)),t}}var r={};if(!J())return A((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 r,e=[];return function n(u){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=pn[u];e.push((function(n){return M.apply(void 0,I([a.apply(void 0,I([n],i,!1)),u,n],i,!1))}));var f={run:function(n){return W(t(e,(function(t,e){var u,i=vn.run({value:n},(function(){return t(n)}));i.pass||e(K(!!i.pass,null!==(u=B(r,n,i.message))&&void 0!==u?u:i.message))})),K(!0))},test:function(n){return f.run(n).pass},message:function(n){return n&&(r=n),f}};return J()?f=new Proxy(f,{get:function(t,r){return pn[r]?n(r):t[r]}}):(A((function(t){f[t]=n(t)})),f)}}(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 _=Object.assign,z=e(u),C=e(i),D=e(o),G=e(f),H=e(s),L=e(c),Q=e(p),Y=e(h),Z=e(y),$=e(g),nn=e(m),tn=e(b),rn=e(O),en=e(x),un=e(E),on=e(w),an=e(T),fn=e(a),sn=e(q),cn=e(j),ln=e(S),pn={condition:function(n,t){try{return t(n)}catch(n){return!1}},doesNotEndWith:G,doesNotStartWith:e(P),endsWith:f,equals:s,greaterThan:l,greaterThanOrEquals:v,gt:l,gte:v,inside:y,isArray:h,isBetween:g,isBlank:m,isBoolean:b,isEmpty:E,isEven:function(n){return!!c(n)&&0==n%2},isFalsy:sn,isKeyOf:w,isNaN:T,isNegative:function(n){return N(n,0)},isNotArray:Y,isNotBetween:$,isNotBlank:nn,isNotBoolean:tn,isNotEmpty:un,isNotKeyOf:on,isNotNaN:an,isNotNull:z,isNotNullish:D,isNotNumber:rn,isNotNumeric:L,isNotString:fn,isNotUndefined:C,isNotValueOf:cn,isNull:u,isNullish:o,isNumber:O,isNumeric:c,isOdd:function(n){return!!c(n)&&0!=n%2},isPositive:function(n){return l(n,0)},isString:a,isTruthy:q,isUndefined:i,isValueOf:j,lengthEquals:x,lengthNotEquals:en,lessThan:N,lessThanOrEquals:d,longerThan:function(n,t){return l(n.length,t)},longerThanOrEquals:function(n,t){return v(n.length,t)},lt:N,lte:d,matches:S,notEquals:H,notInside:Z,notMatches:ln,numberEquals:p,numberNotEquals:Q,shorterThan:function(n,t){return N(n.length,t)},shorterThanOrEquals:function(n,t){return d(n.length,t)},startsWith:P},vn=function(n){function t(t,u){var i,o,a=r();return t=_({},a||{},null!==(i=B(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){return k(e.ctx,W(n,"Context was used after it was closed")),e.ctx}}}((function(n,t){var r={value:n.value,meta:n.meta||{}};return t?n.set?_(r,{parent:function(){return t?{value:t.value,meta:t.meta,parent:t.parent}:t}}):t:_(r,{parent:F})})),hn=function(){function n(){if(!J())return A((function(n){t[n]=U(n)})),_(R,t)}var t={context:function(){return vn.useX()},extend:function(t){_(pn,t),n()}};return n(),new Proxy(_(R,t),{get:function(n,t){return t in n?n[t]:pn[t]?U(t):void 0}})}();hn.extend({isArrayOf:function(n,r){return W(t(n,(function(n,t,e){(e=vn.run({value:n,set:!0,meta:{index:e}},(function(){return V(r,n)}))).pass||t(e)})),K(!0))},loose:X,optional:function(n,t){return o(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,44 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function isFunction(value) {
|
|
8
|
+
return typeof value === 'function';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function optionalFunctionValue(value) {
|
|
12
|
+
var args = [];
|
|
13
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
14
|
+
args[_i - 1] = arguments[_i];
|
|
15
|
+
}
|
|
16
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function defaultTo(callback, defaultValue) {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A safe hasOwnProperty access
|
|
26
|
+
*/
|
|
27
|
+
function hasOwnProperty(obj, key) {
|
|
28
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function invariant(condition,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
33
|
+
message) {
|
|
34
|
+
if (condition) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// If message is a string object (rather than string literal)
|
|
38
|
+
// Throw the value directly as a string
|
|
39
|
+
// Alternatively, throw an error with the message
|
|
40
|
+
throw message instanceof String
|
|
41
|
+
? message.valueOf()
|
|
42
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
43
|
+
}
|
|
44
|
+
|
|
7
45
|
function isNumeric(value) {
|
|
8
46
|
var str = String(value);
|
|
9
47
|
var num = Number(value);
|
|
@@ -15,35 +53,62 @@
|
|
|
15
53
|
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
16
54
|
}
|
|
17
55
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
function hasOwnProperty(obj, key) {
|
|
22
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
56
|
+
function isPositive(value) {
|
|
57
|
+
return greaterThan(value, 0);
|
|
23
58
|
}
|
|
24
59
|
|
|
60
|
+
var Severity;
|
|
61
|
+
(function (Severity) {
|
|
62
|
+
Severity["WARNINGS"] = "warnings";
|
|
63
|
+
Severity["ERRORS"] = "errors";
|
|
64
|
+
})(Severity || (Severity = {}));
|
|
65
|
+
var SeverityCount;
|
|
66
|
+
(function (SeverityCount) {
|
|
67
|
+
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
68
|
+
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
69
|
+
})(SeverityCount || (SeverityCount = {}));
|
|
70
|
+
|
|
71
|
+
// eslint-disable-next-line max-lines-per-function
|
|
25
72
|
function parse(res) {
|
|
73
|
+
invariant(res && hasOwnProperty(res, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
|
|
26
74
|
var testedStorage = {};
|
|
27
75
|
var selectors = {
|
|
28
|
-
invalid:
|
|
29
|
-
tested:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (hasOwnProperty(testedStorage, fieldName))
|
|
34
|
-
return testedStorage[fieldName];
|
|
35
|
-
testedStorage[fieldName] =
|
|
36
|
-
hasOwnProperty(res.tests, fieldName) &&
|
|
37
|
-
greaterThan(res.tests[fieldName].testCount, 0);
|
|
38
|
-
return selectors.tested(fieldName);
|
|
39
|
-
},
|
|
40
|
-
untested: function (fieldName) {
|
|
41
|
-
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
42
|
-
},
|
|
43
|
-
valid: res.isValid,
|
|
44
|
-
warning: res.hasWarnings
|
|
76
|
+
invalid: hasErrors,
|
|
77
|
+
tested: isTested,
|
|
78
|
+
untested: isUntested,
|
|
79
|
+
valid: isValid,
|
|
80
|
+
warning: hasWarnings
|
|
45
81
|
};
|
|
46
82
|
return selectors;
|
|
83
|
+
function isTested(fieldName) {
|
|
84
|
+
if (!fieldName) {
|
|
85
|
+
return isPositive(res.testCount);
|
|
86
|
+
}
|
|
87
|
+
if (hasOwnProperty(testedStorage, fieldName))
|
|
88
|
+
return testedStorage[fieldName];
|
|
89
|
+
testedStorage[fieldName] =
|
|
90
|
+
hasOwnProperty(res.tests, fieldName) &&
|
|
91
|
+
isPositive(res.tests[fieldName].testCount);
|
|
92
|
+
return selectors.tested(fieldName);
|
|
93
|
+
}
|
|
94
|
+
function isUntested(fieldName) {
|
|
95
|
+
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
96
|
+
}
|
|
97
|
+
function isValid(fieldName) {
|
|
98
|
+
var _a;
|
|
99
|
+
return fieldName ? Boolean((_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : res.valid;
|
|
100
|
+
}
|
|
101
|
+
function hasWarnings(fieldName) {
|
|
102
|
+
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
103
|
+
}
|
|
104
|
+
function hasErrors(fieldName) {
|
|
105
|
+
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
106
|
+
}
|
|
107
|
+
function hasFailures(countKey, fieldName) {
|
|
108
|
+
var _a;
|
|
109
|
+
var failureCount = defaultTo(fieldName ? (_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[countKey] : res[countKey], 0);
|
|
110
|
+
return isPositive(failureCount);
|
|
111
|
+
}
|
|
47
112
|
}
|
|
48
113
|
|
|
49
114
|
exports.parse = parse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(e
|
|
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){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return"function"==typeof t?t.apply(void 0,e):t}function n(t){var e=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(e))}function r(t,e){return n(t)&&n(e)&&Number(t)>Number(e)}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 n(n,o){var i,u;return n=o?null===(i=t.tests[o])||void 0===i?void 0:i[n]:t[n],r(i=null!==(u=e(n))&&void 0!==u?u:0,0)}!function(t,n){if(!t)throw n instanceof String?n.valueOf():Error(n?e(n):n)}(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 n(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)&&r(t.tests[e].testCount,0),i.tested(e)):r(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 n(u.WARN_COUNT,t)}};return i},Object.defineProperty(t,"__esModule",{value:!0})}));
|