vest 4.2.2 → 4.2.3-dev-87ebfa
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 +21 -8
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +27 -59
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/promisify.development.js +21 -8
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +312 -304
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +21 -8
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +27 -59
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/promisify.development.js +21 -8
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +312 -304
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +21 -8
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +73 -83
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +18 -20
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +18 -20
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/promisify.development.js +21 -8
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +269 -268
- package/dist/umd/vest.production.js +1 -1
- package/package.json +3 -3
- package/testUtils/mockThrowError.ts +3 -6
- package/types/classnames.d.ts +2 -1
- package/types/parser.d.ts +2 -1
- package/types/promisify.d.ts +2 -1
- package/types/vest.d.ts +56 -55
|
@@ -4,11 +4,26 @@ function isFunction(value) {
|
|
|
4
4
|
return typeof value === 'function';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function optionalFunctionValue(value) {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i - 1] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function invariant(condition,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
17
|
+
message) {
|
|
18
|
+
if (condition) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// If message is a string object (rather than string literal)
|
|
22
|
+
// Throw the value directly as a string
|
|
23
|
+
// Alternatively, throw an error with the message
|
|
24
|
+
throw message instanceof String
|
|
25
|
+
? message.valueOf()
|
|
26
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
function isNumeric(value) {
|
|
@@ -58,9 +73,7 @@ function parse(res) {
|
|
|
58
73
|
*/
|
|
59
74
|
function classnames(res, classes) {
|
|
60
75
|
if (classes === void 0) { classes = {}; }
|
|
61
|
-
|
|
62
|
-
throwError("classnames: Expected first argument to be Vest's result object.");
|
|
63
|
-
}
|
|
76
|
+
invariant(res && isFunction(res.hasErrors), "classnames: Expected first argument to be Vest's result object.");
|
|
64
77
|
var selectors = parse(res);
|
|
65
78
|
return function (key) {
|
|
66
79
|
var classesArray = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t){return"function"==typeof t}function r(r,n){
|
|
1
|
+
"use strict";function t(t){return"function"==typeof t}function r(r,n){if(!r)throw n instanceof String?n.valueOf():Error(n?function(r){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t(r)?r.apply(void 0,n):r}(n):n)}function n(t){var r=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(r))}function e(t,r){return n(t)&&n(r)&&Number(t)>Number(r)}function u(t,r){return Object.prototype.hasOwnProperty.call(t,r)}module.exports=function(n,s){void 0===s&&(s={}),r(n&&t(n.hasErrors),"classnames: Expected first argument to be Vest's result object.");var i=function(t){var r={},n={invalid:t.hasErrors,tested:function(s){return s?u(r,s)?r[s]:(r[s]=u(t.tests,s)&&e(t.tests[s].testCount,0),n.tested(s)):e(t.testCount,0)},untested:function(r){return 0===t.testCount||!n.tested(r)},valid:t.isValid,warning:t.hasWarnings};return n}(n);return function(r){var n,e=[];for(n in s){var u=n;t(i[u])&&i[u](r)&&e.push(s[u])}return e.join(" ")}};
|
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
var n4s = require('n4s');
|
|
4
4
|
|
|
5
|
+
function isFunction(value) {
|
|
6
|
+
return typeof value === 'function';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function optionalFunctionValue(value) {
|
|
10
|
+
var args = [];
|
|
11
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
12
|
+
args[_i - 1] = arguments[_i];
|
|
13
|
+
}
|
|
14
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function invariant(condition,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
19
|
+
message) {
|
|
20
|
+
if (condition) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// If message is a string object (rather than string literal)
|
|
24
|
+
// Throw the value directly as a string
|
|
25
|
+
// Alternatively, throw an error with the message
|
|
26
|
+
throw message instanceof String
|
|
27
|
+
? message.valueOf()
|
|
28
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
29
|
+
}
|
|
30
|
+
|
|
5
31
|
function mapFirst(array, callback) {
|
|
6
32
|
var broke = false;
|
|
7
33
|
var breakoutValue = null;
|
|
@@ -17,61 +43,11 @@ function mapFirst(array, callback) {
|
|
|
17
43
|
}
|
|
18
44
|
}
|
|
19
45
|
|
|
20
|
-
function isFunction(value) {
|
|
21
|
-
return typeof value === 'function';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function optionalFunctionValue(value) {
|
|
25
|
-
var args = [];
|
|
26
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
27
|
-
args[_i - 1] = arguments[_i];
|
|
28
|
-
}
|
|
29
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
46
|
function defaultTo(callback, defaultValue) {
|
|
33
47
|
var _a;
|
|
34
48
|
return (_a = optionalFunctionValue(callback)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
35
49
|
}
|
|
36
50
|
|
|
37
|
-
/**
|
|
38
|
-
* Throws a timed out error.
|
|
39
|
-
*/
|
|
40
|
-
function throwError(devMessage, productionMessage) {
|
|
41
|
-
throw new Error(devMessage );
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A safe hasOwnProperty access
|
|
46
|
-
*/
|
|
47
|
-
function hasOwnProperty(obj, key) {
|
|
48
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isNumber(value) {
|
|
52
|
-
return Boolean(typeof value === 'number');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function lengthEquals(value, arg1) {
|
|
56
|
-
return value.length === Number(arg1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function isEmpty(value) {
|
|
60
|
-
if (!value) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
else if (isNumber(value)) {
|
|
64
|
-
return value === 0;
|
|
65
|
-
}
|
|
66
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
67
|
-
return lengthEquals(value, 0);
|
|
68
|
-
}
|
|
69
|
-
else if (typeof value === 'object') {
|
|
70
|
-
return lengthEquals(Object.keys(value), 0);
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
51
|
function ruleReturn(pass, message) {
|
|
76
52
|
var output = { pass: pass };
|
|
77
53
|
if (message) {
|
|
@@ -106,15 +82,7 @@ function compose() {
|
|
|
106
82
|
}
|
|
107
83
|
return Object.assign(function (value) {
|
|
108
84
|
var res = run(value);
|
|
109
|
-
|
|
110
|
-
if (isEmpty(res.message)) {
|
|
111
|
-
throwError();
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// Explicitly throw a string so that vest.test can pick it up as the validation error message
|
|
115
|
-
throw res.message;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
85
|
+
invariant(res.pass, new String(res.message));
|
|
118
86
|
}, {
|
|
119
87
|
run: run,
|
|
120
88
|
test: function (value) { return run(value).pass; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=require("n4s");function r(n
|
|
1
|
+
"use strict";var n=require("n4s");function r(n){return"function"==typeof n}function t(n){for(var t=[],u=1;u<arguments.length;u++)t[u-1]=arguments[u];return r(n)?n.apply(void 0,t):n}function u(n,r){if(!n)throw r instanceof String?r.valueOf():Error(r?t(r):r)}function e(n,r){function t(n){u=!0,e=n}for(var u=!1,e=null,o=0;o<n.length;o++)if(r(n[o],t,o),u)return e}function o(n,r){return n={pass:n},r&&(n.message=r),n}function i(n){return function(n,r){var u;return null!==(u=t(n))&&void 0!==u?u:r}(n,o(!0))}function f(n,r){try{return n.run(r)}catch(n){return o(!1)}}module.exports=function(){function r(r){return n.ctx.run({value:r},(function(){return i(e(t,(function(n,t){(n=f(n,r)).pass||t(n)})))}))}for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return Object.assign((function(n){u((n=r(n)).pass,new String(n.message))}),{run:r,test:function(n){return r(n).pass}})};
|
|
@@ -4,11 +4,26 @@ function isFunction(value) {
|
|
|
4
4
|
return typeof value === 'function';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function optionalFunctionValue(value) {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i - 1] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function invariant(condition,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
17
|
+
message) {
|
|
18
|
+
if (condition) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// If message is a string object (rather than string literal)
|
|
22
|
+
// Throw the value directly as a string
|
|
23
|
+
// Alternatively, throw an error with the message
|
|
24
|
+
throw message instanceof String
|
|
25
|
+
? message.valueOf()
|
|
26
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
var promisify = function (validatorFn) {
|
|
@@ -17,9 +32,7 @@ var promisify = function (validatorFn) {
|
|
|
17
32
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18
33
|
args[_i] = arguments[_i];
|
|
19
34
|
}
|
|
20
|
-
|
|
21
|
-
throwError('promisify: Expected validatorFn to be a function.');
|
|
22
|
-
}
|
|
35
|
+
invariant(isFunction(validatorFn), 'promisify: Expected validatorFn to be a function.');
|
|
23
36
|
return new Promise(function (resolve) { return validatorFn.apply(void 0, args).done(resolve); });
|
|
24
37
|
};
|
|
25
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function n(n){return"function"==typeof n}function r(
|
|
1
|
+
"use strict";function n(n){return"function"==typeof n}function t(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return n(t)?t.apply(void 0,r):t}(r):r)}module.exports=function(r){return function(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];return t(n(r),"promisify: Expected validatorFn to be a function."),new Promise((function(n){return r.apply(void 0,o).done(n)}))}};
|