vest 4.4.3-dev-c786f7 → 4.6.0

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 (33) hide show
  1. package/dist/cjs/classnames.development.js +13 -36
  2. package/dist/cjs/classnames.production.js +1 -1
  3. package/dist/cjs/parser.development.js +13 -36
  4. package/dist/cjs/parser.production.js +1 -1
  5. package/dist/cjs/vest.development.js +232 -187
  6. package/dist/cjs/vest.production.js +1 -1
  7. package/dist/es/classnames.development.js +14 -37
  8. package/dist/es/classnames.production.js +1 -1
  9. package/dist/es/parser.development.js +14 -37
  10. package/dist/es/parser.production.js +1 -1
  11. package/dist/es/vest.development.js +233 -189
  12. package/dist/es/vest.production.js +1 -1
  13. package/dist/umd/classnames.development.js +19 -96
  14. package/dist/umd/classnames.production.js +1 -1
  15. package/dist/umd/enforce/compose.development.js +9 -665
  16. package/dist/umd/enforce/compose.production.js +1 -1
  17. package/dist/umd/enforce/compounds.development.js +17 -667
  18. package/dist/umd/enforce/compounds.production.js +1 -1
  19. package/dist/umd/enforce/schema.development.js +12 -668
  20. package/dist/umd/enforce/schema.production.js +1 -1
  21. package/dist/umd/parser.development.js +18 -95
  22. package/dist/umd/parser.production.js +1 -1
  23. package/dist/umd/promisify.development.js +5 -31
  24. package/dist/umd/promisify.production.js +1 -1
  25. package/dist/umd/vest.development.js +336 -1067
  26. package/dist/umd/vest.production.js +1 -1
  27. package/package.json +4 -4
  28. package/types/enforce/compose.d.ts +2 -1
  29. package/types/enforce/compounds.d.ts +8 -9
  30. package/types/enforce/schema.d.ts +7 -5
  31. package/types/parser.d.ts +8 -7
  32. package/types/promisify.d.ts +20 -35
  33. package/types/vest.d.ts +79 -81
@@ -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 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})}));
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,113 +1,36 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}));
5
- }(this, (function (exports) { 'use strict';
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
-
18
- function isFunction(value) {
19
- return typeof value === 'function';
20
- }
21
-
22
- function optionalFunctionValue(value) {
23
- var args = [];
24
- for (var _i = 1; _i < arguments.length; _i++) {
25
- args[_i - 1] = arguments[_i];
26
- }
27
- return isFunction(value) ? value.apply(void 0, args) : value;
28
- }
29
-
30
- function defaultTo(value, defaultValue) {
31
- var _a;
32
- return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
33
- }
34
-
35
- /**
36
- * A safe hasOwnProperty access
37
- */
38
- function hasOwnProperty(obj, key) {
39
- return Object.prototype.hasOwnProperty.call(obj, key);
40
- }
41
-
42
- function invariant(condition,
43
- // eslint-disable-next-line @typescript-eslint/ban-types
44
- message) {
45
- if (condition) {
46
- return;
47
- }
48
- // If message is a string object (rather than string literal)
49
- // Throw the value directly as a string
50
- // Alternatively, throw an error with the message
51
- throw message instanceof String
52
- ? message.valueOf()
53
- : new Error(message ? optionalFunctionValue(message) : message);
54
- }
55
-
56
- function isPositive(value) {
57
- return greaterThan(value, 0);
58
- }
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
72
- function parse(res) {
73
- invariant(res && hasOwnProperty(res, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest'), require('vest-utils')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vest', 'vest-utils'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}, global.vest, global['vest-utils']));
5
+ }(this, (function (exports, vest, vestUtils) { 'use strict';
6
+
7
+ // eslint-disable-next-line max-statements
8
+ function parse(summary) {
9
+ vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
10
+ var sel = vest.suiteSelectors(summary);
74
11
  var testedStorage = {};
75
12
  var selectors = {
76
- invalid: hasErrors,
13
+ invalid: sel.hasErrors,
77
14
  tested: isTested,
78
15
  untested: isUntested,
79
- valid: isValid,
80
- warning: hasWarnings
16
+ valid: sel.isValid,
17
+ warning: sel.hasWarnings
81
18
  };
82
19
  return selectors;
20
+ // Booleans
83
21
  function isTested(fieldName) {
84
22
  if (!fieldName) {
85
- return isPositive(res.testCount);
23
+ return vestUtils.isPositive(summary.testCount);
86
24
  }
87
- if (hasOwnProperty(testedStorage, fieldName))
25
+ if (vestUtils.hasOwnProperty(testedStorage, fieldName))
88
26
  return testedStorage[fieldName];
89
27
  testedStorage[fieldName] =
90
- hasOwnProperty(res.tests, fieldName) &&
91
- isPositive(res.tests[fieldName].testCount);
28
+ vestUtils.hasOwnProperty(summary.tests, fieldName) &&
29
+ vestUtils.isPositive(summary.tests[fieldName].testCount);
92
30
  return selectors.tested(fieldName);
93
31
  }
94
32
  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);
33
+ return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
111
34
  }
112
35
  }
113
36
 
@@ -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){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})}));
1
+ "use strict";!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest","vest-utils"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).parser={},e.vest,e["vest-utils"])}(this,(function(e,t,s){e.parse=function(e){s.invariant(e&&s.hasOwnProperty(e,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var i=t.suiteSelectors(e),n={},r={invalid:i.hasErrors,tested:function(t){return t?s.hasOwnProperty(n,t)?n[t]:(n[t]=s.hasOwnProperty(e.tests,t)&&s.isPositive(e.tests[t].testCount),r.tested(t)):s.isPositive(e.testCount)},untested:function(t){return!(s.isPositive(e.testCount)&&r.tested(t))},valid:i.isValid,warning:i.hasWarnings};return r},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1,34 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
- typeof define === 'function' && define.amd ? define(factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.promisify = factory());
5
- }(this, (function () { 'use strict';
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 invariant(condition,
20
- // eslint-disable-next-line @typescript-eslint/ban-types
21
- message) {
22
- if (condition) {
23
- return;
24
- }
25
- // If message is a string object (rather than string literal)
26
- // Throw the value directly as a string
27
- // Alternatively, throw an error with the message
28
- throw message instanceof String
29
- ? message.valueOf()
30
- : new Error(message ? optionalFunctionValue(message) : message);
31
- }
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vest-utils')) :
3
+ typeof define === 'function' && define.amd ? define(['vest-utils'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.promisify = factory(global['vest-utils']));
5
+ }(this, (function (vestUtils) { 'use strict';
32
6
 
33
7
  var promisify = function (validatorFn) {
34
8
  return function () {
@@ -36,7 +10,7 @@
36
10
  for (var _i = 0; _i < arguments.length; _i++) {
37
11
  args[_i] = arguments[_i];
38
12
  }
39
- invariant(isFunction(validatorFn), 'promisify: Expected validatorFn to be a function.');
13
+ vestUtils.invariant(vestUtils.isFunction(validatorFn), 'promisify: Expected validatorFn to be a function.');
40
14
  return new Promise(function (resolve) { return validatorFn.apply(void 0, args).done(resolve); });
41
15
  };
42
16
  };
@@ -1 +1 @@
1
- "use strict";!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).promisify=e()}(this,(function(){function n(n,e){if(!n)throw e instanceof String?e.valueOf():Error(e?function(n){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];return"function"==typeof n?n.apply(void 0,e):n}(e):e)}return function(e){return function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];return n("function"==typeof e,"promisify: Expected validatorFn to be a function."),new Promise((function(n){return e.apply(void 0,o).done(n)}))}}}));
1
+ "use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("vest-utils")):"function"==typeof define&&define.amd?define(["vest-utils"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).promisify=n(e["vest-utils"])}(this,(function(e){return function(n){return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.invariant(e.isFunction(n),"promisify: Expected validatorFn to be a function."),new Promise((function(e){return n.apply(void 0,t).done(e)}))}}}));