vest 4.5.0 → 5.0.0-dev-781e21

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 (34) hide show
  1. package/dist/cjs/enforce/compose.development.js +1 -1
  2. package/dist/cjs/enforce/compose.production.js +1 -1
  3. package/dist/cjs/enforce/compounds.development.js +1 -1
  4. package/dist/cjs/enforce/compounds.production.js +1 -1
  5. package/dist/cjs/enforce/schema.development.js +1 -1
  6. package/dist/cjs/enforce/schema.production.js +1 -1
  7. package/dist/cjs/vest.development.js +146 -95
  8. package/dist/cjs/vest.production.js +1 -1
  9. package/dist/es/enforce/compose.development.js +1 -1
  10. package/dist/es/enforce/compose.production.js +1 -1
  11. package/dist/es/enforce/compounds.development.js +1 -1
  12. package/dist/es/enforce/compounds.production.js +1 -1
  13. package/dist/es/enforce/schema.development.js +1 -1
  14. package/dist/es/enforce/schema.production.js +1 -1
  15. package/dist/es/vest.development.js +148 -97
  16. package/dist/es/vest.production.js +1 -1
  17. package/dist/umd/classnames.development.js +11 -59
  18. package/dist/umd/classnames.production.js +1 -1
  19. package/dist/umd/enforce/compose.development.js +9 -682
  20. package/dist/umd/enforce/compose.production.js +1 -1
  21. package/dist/umd/enforce/compounds.development.js +17 -684
  22. package/dist/umd/enforce/compounds.production.js +1 -1
  23. package/dist/umd/enforce/schema.development.js +12 -685
  24. package/dist/umd/enforce/schema.production.js +1 -1
  25. package/dist/umd/parser.development.js +10 -58
  26. package/dist/umd/parser.production.js +1 -1
  27. package/dist/umd/promisify.development.js +5 -31
  28. package/dist/umd/promisify.production.js +1 -1
  29. package/dist/umd/vest.development.js +255 -997
  30. package/dist/umd/vest.production.js +1 -1
  31. package/package.json +3 -3
  32. package/types/enforce/compounds.d.ts +6 -8
  33. package/types/enforce/schema.d.ts +5 -4
  34. package/types/vest.d.ts +36 -28
@@ -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,60 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vest'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.parser = {}, global.vest));
5
- }(this, (function (exports, vest) { '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
- /**
31
- * A safe hasOwnProperty access
32
- */
33
- function hasOwnProperty(obj, key) {
34
- return Object.prototype.hasOwnProperty.call(obj, key);
35
- }
36
-
37
- function invariant(condition,
38
- // eslint-disable-next-line @typescript-eslint/ban-types
39
- message) {
40
- if (condition) {
41
- return;
42
- }
43
- // If message is a string object (rather than string literal)
44
- // Throw the value directly as a string
45
- // Alternatively, throw an error with the message
46
- throw message instanceof String
47
- ? message.valueOf()
48
- : new Error(message ? optionalFunctionValue(message) : message);
49
- }
50
-
51
- function isPositive(value) {
52
- return greaterThan(value, 0);
53
- }
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';
54
6
 
55
7
  // eslint-disable-next-line max-statements
56
8
  function parse(summary) {
57
- invariant(summary && hasOwnProperty(summary, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
9
+ vestUtils.invariant(summary && vestUtils.hasOwnProperty(summary, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
58
10
  var sel = vest.suiteSelectors(summary);
59
11
  var testedStorage = {};
60
12
  var selectors = {
@@ -68,17 +20,17 @@
68
20
  // Booleans
69
21
  function isTested(fieldName) {
70
22
  if (!fieldName) {
71
- return isPositive(summary.testCount);
23
+ return vestUtils.isPositive(summary.testCount);
72
24
  }
73
- if (hasOwnProperty(testedStorage, fieldName))
25
+ if (vestUtils.hasOwnProperty(testedStorage, fieldName))
74
26
  return testedStorage[fieldName];
75
27
  testedStorage[fieldName] =
76
- hasOwnProperty(summary.tests, fieldName) &&
77
- isPositive(summary.tests[fieldName].testCount);
28
+ vestUtils.hasOwnProperty(summary.tests, fieldName) &&
29
+ vestUtils.isPositive(summary.tests[fieldName].testCount);
78
30
  return selectors.tested(fieldName);
79
31
  }
80
32
  function isUntested(fieldName) {
81
- return !(isPositive(summary.testCount) && selectors.tested(fieldName));
33
+ return !(vestUtils.isPositive(summary.testCount) && selectors.tested(fieldName));
82
34
  }
83
35
  }
84
36
 
@@ -1 +1 @@
1
- "use strict";!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vest")):"function"==typeof define&&define.amd?define(["exports","vest"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).parser={},e.vest)}(this,(function(e,t){function r(e){var t=Number(e);return!(isNaN(parseFloat(String(e)))||isNaN(Number(e))||!isFinite(t))}function n(e,t){return r(e)&&r(t)&&Number(e)>Number(t)}e.parse=function(e){!function(e,t){if(!e)throw t instanceof String?t.valueOf():Error(t?function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,t):e}(t):t)}(e&&Object.prototype.hasOwnProperty.call(e,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var r=t.suiteSelectors(e),o={},s={invalid:r.hasErrors,tested:function(t){return t?Object.prototype.hasOwnProperty.call(o,t)?o[t]:(o[t]=Object.prototype.hasOwnProperty.call(e.tests,t)&&n(e.tests[t].testCount,0),s.tested(t)):n(e.testCount,0)},untested:function(t){return!(n(e.testCount,0)&&s.tested(t))},valid:r.isValid,warning:r.hasWarnings};return s},Object.defineProperty(e,"__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)}))}}}));