n4s 4.1.8 → 4.1.9-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/compose.development.js +5 -58
- package/dist/cjs/compose.production.js +1 -1
- package/dist/cjs/compounds.development.js +8 -51
- package/dist/cjs/compounds.production.js +1 -1
- package/dist/cjs/n4s.development.js +66 -211
- package/dist/cjs/n4s.production.js +1 -1
- package/dist/cjs/schema.development.js +5 -57
- package/dist/cjs/schema.production.js +1 -1
- package/dist/es/compose.development.js +1 -54
- package/dist/es/compose.production.js +1 -1
- package/dist/es/compounds.development.js +2 -45
- package/dist/es/compounds.production.js +1 -1
- package/dist/es/n4s.development.js +4 -149
- package/dist/es/n4s.production.js +1 -1
- package/dist/es/schema.development.js +1 -53
- package/dist/es/schema.production.js +1 -1
- package/dist/umd/compose.development.js +7 -7
- package/dist/umd/compose.production.js +1 -1
- package/dist/umd/compounds.development.js +26 -26
- package/dist/umd/compounds.production.js +1 -1
- package/dist/umd/n4s.development.js +117 -117
- package/dist/umd/n4s.production.js +1 -1
- package/dist/umd/schema.development.js +34 -34
- package/package.json +3 -2
- package/types/compose.d.ts +15 -31
- package/types/compounds.d.ts +15 -31
- package/types/n4s.d.ts +15 -31
- package/types/schema.d.ts +15 -31
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.n4s = {}));
|
|
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: [] };
|
|
@@ -544,23 +561,6 @@
|
|
|
544
561
|
}
|
|
545
562
|
}
|
|
546
563
|
|
|
547
|
-
function mapFirst(array, callback) {
|
|
548
|
-
var broke = false;
|
|
549
|
-
var breakoutValue = null;
|
|
550
|
-
for (var i = 0; i < array.length; i++) {
|
|
551
|
-
callback(array[i], breakout, i);
|
|
552
|
-
if (broke) {
|
|
553
|
-
return breakoutValue;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function breakout(conditional, value) {
|
|
557
|
-
if (conditional) {
|
|
558
|
-
broke = true;
|
|
559
|
-
breakoutValue = value;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
564
|
// eslint-disable-next-line max-lines-per-function
|
|
565
565
|
function genEnforceLazy(key) {
|
|
566
566
|
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).n4s={})}(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).n4s={})}(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 s(n){return void 0===n}function f(n){return null===n||s(n)}function a(n){return"function"==typeof n}function c(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return a(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 N(n){return!!n===n}function g(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 y(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 S(n){return Number.isNaN(n)}function j(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 cn){var r=cn[t];a(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 a(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(N(n)||n&&N(n.pass),"Incorrect return value for rule: "+JSON.stringify(n)),N(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=ln.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=cn[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=cn[e];r.push((function(n){return M.apply(void 0,I([o.apply(void 0,I([n],u,!1)),e,n],u,!1))}));var s={run:function(n){return l(g(r,(function(r,e){var u,i=ln.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 s.run(n).pass},message:function(n){return n&&(t=n),s}};return J()?s=new Proxy(s,{get:function(t,r){return cn[r]?n(r):t[r]}}):(k((function(t){s[t]=n(t)})),s)}}(n)}var V=t(r),X=t(e),_=t(u),z=t(o),C=t(s),D=t(f),G=t(p),H=Object.assign,L=t(d),Q=t(y),Y=t(m),Z=t(O),$=t(w),nn=t(T),tn=t(N),rn=t(q),en=t(S),un=t(j),on=t(h),sn=t(P),fn=t(A),an=t(B),cn={condition:function(n,t){try{return t(n)}catch(n){return!1}},doesNotEndWith:Q,doesNotStartWith:t(W),endsWith:y,equals:m,greaterThan:i,greaterThanOrEquals:b,gt:i,gte:b,inside:O,isArray:p,isBetween:w,isBlank:T,isBoolean:N,isEmpty:d,isEven:function(n){return!!r(n)&&0==n%2},isFalsy:sn,isKeyOf:q,isNaN:S,isNegative:function(n){return x(n,0)},isNotArray:G,isNotBetween:$,isNotBlank:nn,isNotBoolean:tn,isNotEmpty:L,isNotKeyOf:rn,isNotNaN:en,isNotNull:z,isNotNullish:D,isNotNumber:un,isNotNumeric:V,isNotString:on,isNotUndefined:C,isNotValueOf:fn,isNull:o,isNullish:f,isNumber:j,isNumeric:r,isOdd:function(n){return!!r(n)&&0!=n%2},isPositive:function(n){return i(n,0)},isString:h,isTruthy:P,isUndefined:s,isValueOf:A,lengthEquals:u,lengthNotEquals:_,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:Y,notInside:Z,notMatches:an,numberEquals:e,numberNotEquals:X,shorterThan:function(n,t){return x(n.length,t)},shorterThanOrEquals:function(n,t){return E(n.length,t)},startsWith:W},ln=function(n){function t(t,u){var i,o,s=r();return t=H({},s||{},null!==(i=c(n,t,s))&&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?H(r,{parent:function(){return t?{value:t.value,meta:t.meta,parent:t.parent}:t}}):t:H(r,{parent:F})}));V=function(){function n(){if(!J())return k((function(n){t[n]=U(n)})),H(R,t)}var t={context:function(){return ln.useX()},extend:function(t){H(cn,t),n()}};return n(),new Proxy(H(R,t),{get:function(n,t){return t in n?n[t]:cn[t]?U(t):void 0}})}(),n.ctx=ln,n.enforce=V,Object.defineProperty(n,"__esModule",{value:!0})}));
|
|
@@ -4,21 +4,16 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s));
|
|
5
5
|
}(this, (function (exports, n4s) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (conditional) {
|
|
18
|
-
broke = true;
|
|
19
|
-
breakoutValue = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
7
|
+
function isNull(value) {
|
|
8
|
+
return value === null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isUndefined(value) {
|
|
12
|
+
return value === undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isNullish(value) {
|
|
16
|
+
return isNull(value) || isUndefined(value);
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
function isFunction(value) {
|
|
@@ -38,6 +33,30 @@
|
|
|
38
33
|
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
39
34
|
}
|
|
40
35
|
|
|
36
|
+
/**
|
|
37
|
+
* A safe hasOwnProperty access
|
|
38
|
+
*/
|
|
39
|
+
function hasOwnProperty(obj, key) {
|
|
40
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function mapFirst(array, callback) {
|
|
44
|
+
var broke = false;
|
|
45
|
+
var breakoutValue = null;
|
|
46
|
+
for (var i = 0; i < array.length; i++) {
|
|
47
|
+
callback(array[i], breakout, i);
|
|
48
|
+
if (broke) {
|
|
49
|
+
return breakoutValue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function breakout(conditional, value) {
|
|
53
|
+
if (conditional) {
|
|
54
|
+
broke = true;
|
|
55
|
+
breakoutValue = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
function ruleReturn(pass, message) {
|
|
42
61
|
var output = { pass: pass };
|
|
43
62
|
if (message) {
|
|
@@ -90,18 +109,6 @@
|
|
|
90
109
|
return passing();
|
|
91
110
|
}
|
|
92
111
|
|
|
93
|
-
function isNull(value) {
|
|
94
|
-
return value === null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function isUndefined(value) {
|
|
98
|
-
return value === undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function isNullish(value) {
|
|
102
|
-
return isNull(value) || isUndefined(value);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
112
|
function optional(value, ruleChain) {
|
|
106
113
|
if (isNullish(value)) {
|
|
107
114
|
return passing();
|
|
@@ -109,13 +116,6 @@
|
|
|
109
116
|
return runLazyRule(ruleChain, value);
|
|
110
117
|
}
|
|
111
118
|
|
|
112
|
-
/**
|
|
113
|
-
* A safe hasOwnProperty access
|
|
114
|
-
*/
|
|
115
|
-
function hasOwnProperty(obj, key) {
|
|
116
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
119
|
function shape(inputObject, shapeObject) {
|
|
120
120
|
var baseRes = loose(inputObject, shapeObject);
|
|
121
121
|
if (!baseRes.pass) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.1.
|
|
2
|
+
"version": "4.1.9-dev-c786f7",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/n4s.js",
|
|
5
5
|
"types": "./types/n4s.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"release": "vx release"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"context": "^2.0.
|
|
13
|
+
"context": "^2.0.8-dev-c786f7",
|
|
14
|
+
"vest-utils": "^0.0.4-dev-c786f7"
|
|
14
15
|
},
|
|
15
16
|
"module": "./dist/es/n4s.production.js",
|
|
16
17
|
"exports": {
|
package/types/compose.d.ts
CHANGED
|
@@ -17,36 +17,20 @@ type KBaseRules = keyof BaseRules;
|
|
|
17
17
|
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
18
18
|
declare function endsWith(value: string, arg1: string): boolean;
|
|
19
19
|
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
20
|
-
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
21
20
|
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
22
21
|
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
23
|
-
// The module is named "isArrayValue" since it
|
|
24
|
-
// is conflicting with a nested npm dependency.
|
|
25
|
-
// We may need to revisit this in the future.
|
|
26
|
-
declare function isArray(value: unknown): value is Array<unknown>;
|
|
27
22
|
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
28
23
|
declare function isBlank(value: unknown): boolean;
|
|
29
|
-
declare function isBoolean(value: unknown): value is boolean;
|
|
30
|
-
declare function isEmpty(value: unknown): boolean;
|
|
31
24
|
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
32
25
|
declare function isNaN(value: unknown): boolean;
|
|
33
26
|
declare function isNegative(value: number | string): boolean;
|
|
34
|
-
declare function isNull(value: unknown): value is null;
|
|
35
|
-
declare function isNullish(value: any): value is null | undefined;
|
|
36
27
|
declare function isNumber(value: unknown): value is number;
|
|
37
|
-
declare function isNumeric(value: string | number): boolean;
|
|
38
|
-
declare function isPositive(value: number | string): boolean;
|
|
39
|
-
declare function isStringValue(v: unknown): v is string;
|
|
40
28
|
declare function isTruthy(value: unknown): boolean;
|
|
41
|
-
declare function isUndefined(value?: unknown): value is undefined;
|
|
42
29
|
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
43
|
-
declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
44
30
|
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
45
31
|
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
46
|
-
declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
|
|
47
32
|
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
48
33
|
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
49
|
-
declare function numberEquals(value: string | number, eq: string | number): boolean;
|
|
50
34
|
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
51
35
|
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
52
36
|
declare function startsWith(value: string, arg1: string): boolean;
|
|
@@ -56,16 +40,16 @@ declare const baseRules: {
|
|
|
56
40
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
57
41
|
endsWith: typeof endsWith;
|
|
58
42
|
equals: typeof equals;
|
|
59
|
-
greaterThan: typeof greaterThan;
|
|
43
|
+
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
60
44
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
61
|
-
gt: typeof greaterThan;
|
|
45
|
+
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
62
46
|
gte: typeof greaterThanOrEquals;
|
|
63
47
|
inside: typeof inside;
|
|
64
|
-
isArray: typeof isArray;
|
|
48
|
+
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
65
49
|
isBetween: typeof isBetween;
|
|
66
50
|
isBlank: typeof isBlank;
|
|
67
|
-
isBoolean: typeof isBoolean;
|
|
68
|
-
isEmpty: typeof isEmpty;
|
|
51
|
+
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
52
|
+
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
69
53
|
isEven: (value: any) => boolean;
|
|
70
54
|
isFalsy: (value: unknown) => boolean;
|
|
71
55
|
isKeyOf: typeof isKeyOf;
|
|
@@ -85,21 +69,21 @@ declare const baseRules: {
|
|
|
85
69
|
isNotString: (v: unknown) => boolean;
|
|
86
70
|
isNotUndefined: (value?: unknown) => boolean;
|
|
87
71
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
88
|
-
isNull: typeof isNull;
|
|
89
|
-
isNullish: typeof isNullish;
|
|
72
|
+
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
73
|
+
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
90
74
|
isNumber: typeof isNumber;
|
|
91
|
-
isNumeric: typeof isNumeric;
|
|
75
|
+
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
92
76
|
isOdd: (value: any) => boolean;
|
|
93
|
-
isPositive: typeof isPositive;
|
|
94
|
-
isString: typeof isStringValue;
|
|
77
|
+
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
78
|
+
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
95
79
|
isTruthy: typeof isTruthy;
|
|
96
|
-
isUndefined: typeof isUndefined;
|
|
80
|
+
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
97
81
|
isValueOf: typeof isValueOf;
|
|
98
|
-
lengthEquals: typeof lengthEquals;
|
|
82
|
+
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
99
83
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
100
84
|
lessThan: typeof lessThan;
|
|
101
85
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
102
|
-
longerThan: typeof longerThan;
|
|
86
|
+
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
103
87
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
104
88
|
lt: typeof lessThan;
|
|
105
89
|
lte: typeof lessThanOrEquals;
|
|
@@ -107,13 +91,13 @@ declare const baseRules: {
|
|
|
107
91
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
108
92
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
109
93
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
110
|
-
numberEquals: typeof numberEquals;
|
|
94
|
+
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
111
95
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
112
96
|
shorterThan: typeof shorterThan;
|
|
113
97
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
114
98
|
startsWith: typeof startsWith;
|
|
115
99
|
};
|
|
116
|
-
type Rules<E =
|
|
100
|
+
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
101
|
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
118
102
|
};
|
|
119
103
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
package/types/compounds.d.ts
CHANGED
|
@@ -17,36 +17,20 @@ type KBaseRules = keyof BaseRules;
|
|
|
17
17
|
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
18
18
|
declare function endsWith(value: string, arg1: string): boolean;
|
|
19
19
|
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
20
|
-
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
21
20
|
declare function greaterThanOrEquals(value: string | number, gte: string | number): boolean;
|
|
22
21
|
declare function inside(value: unknown, arg1: string | unknown[]): boolean;
|
|
23
|
-
// The module is named "isArrayValue" since it
|
|
24
|
-
// is conflicting with a nested npm dependency.
|
|
25
|
-
// We may need to revisit this in the future.
|
|
26
|
-
declare function isArray(value: unknown): value is Array<unknown>;
|
|
27
22
|
declare function isBetween(value: number | string, min: number | string, max: number | string): boolean;
|
|
28
23
|
declare function isBlank(value: unknown): boolean;
|
|
29
|
-
declare function isBoolean(value: unknown): value is boolean;
|
|
30
|
-
declare function isEmpty(value: unknown): boolean;
|
|
31
24
|
declare function isKeyOf(key: string | symbol | number, obj: any): boolean;
|
|
32
25
|
declare function isNaN(value: unknown): boolean;
|
|
33
26
|
declare function isNegative(value: number | string): boolean;
|
|
34
|
-
declare function isNull(value: unknown): value is null;
|
|
35
|
-
declare function isNullish(value: any): value is null | undefined;
|
|
36
27
|
declare function isNumber(value: unknown): value is number;
|
|
37
|
-
declare function isNumeric(value: string | number): boolean;
|
|
38
|
-
declare function isPositive(value: number | string): boolean;
|
|
39
|
-
declare function isStringValue(v: unknown): v is string;
|
|
40
28
|
declare function isTruthy(value: unknown): boolean;
|
|
41
|
-
declare function isUndefined(value?: unknown): value is undefined;
|
|
42
29
|
declare function isValueOf(value: any, objectToCheck: any): boolean;
|
|
43
|
-
declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
44
30
|
declare function lessThan(value: string | number, lt: string | number): boolean;
|
|
45
31
|
declare function lessThanOrEquals(value: string | number, lte: string | number): boolean;
|
|
46
|
-
declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
|
|
47
32
|
declare function longerThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
48
33
|
declare function matches(value: string, regex: RegExp | string): boolean;
|
|
49
|
-
declare function numberEquals(value: string | number, eq: string | number): boolean;
|
|
50
34
|
declare function shorterThan(value: string | unknown[], arg1: string | number): boolean;
|
|
51
35
|
declare function shorterThanOrEquals(value: string | unknown[], arg1: string | number): boolean;
|
|
52
36
|
declare function startsWith(value: string, arg1: string): boolean;
|
|
@@ -56,16 +40,16 @@ declare const baseRules: {
|
|
|
56
40
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
57
41
|
endsWith: typeof endsWith;
|
|
58
42
|
equals: typeof equals;
|
|
59
|
-
greaterThan: typeof greaterThan;
|
|
43
|
+
greaterThan: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
60
44
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
61
|
-
gt: typeof greaterThan;
|
|
45
|
+
gt: typeof import("packages/vest-utils/types/vest-utils").greaterThan;
|
|
62
46
|
gte: typeof greaterThanOrEquals;
|
|
63
47
|
inside: typeof inside;
|
|
64
|
-
isArray: typeof isArray;
|
|
48
|
+
isArray: typeof import("packages/vest-utils/types/vest-utils").isArray;
|
|
65
49
|
isBetween: typeof isBetween;
|
|
66
50
|
isBlank: typeof isBlank;
|
|
67
|
-
isBoolean: typeof isBoolean;
|
|
68
|
-
isEmpty: typeof isEmpty;
|
|
51
|
+
isBoolean: typeof import("packages/vest-utils/types/vest-utils").isBoolean;
|
|
52
|
+
isEmpty: typeof import("packages/vest-utils/types/vest-utils").isEmpty;
|
|
69
53
|
isEven: (value: any) => boolean;
|
|
70
54
|
isFalsy: (value: unknown) => boolean;
|
|
71
55
|
isKeyOf: typeof isKeyOf;
|
|
@@ -85,21 +69,21 @@ declare const baseRules: {
|
|
|
85
69
|
isNotString: (v: unknown) => boolean;
|
|
86
70
|
isNotUndefined: (value?: unknown) => boolean;
|
|
87
71
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
88
|
-
isNull: typeof isNull;
|
|
89
|
-
isNullish: typeof isNullish;
|
|
72
|
+
isNull: typeof import("packages/vest-utils/types/vest-utils").isNull;
|
|
73
|
+
isNullish: typeof import("packages/vest-utils/types/vest-utils").isNullish;
|
|
90
74
|
isNumber: typeof isNumber;
|
|
91
|
-
isNumeric: typeof isNumeric;
|
|
75
|
+
isNumeric: typeof import("packages/vest-utils/types/vest-utils").isNumeric;
|
|
92
76
|
isOdd: (value: any) => boolean;
|
|
93
|
-
isPositive: typeof isPositive;
|
|
94
|
-
isString: typeof isStringValue;
|
|
77
|
+
isPositive: typeof import("packages/vest-utils/types/vest-utils").isPositive;
|
|
78
|
+
isString: typeof import("packages/vest-utils/types/vest-utils").isStringValue;
|
|
95
79
|
isTruthy: typeof isTruthy;
|
|
96
|
-
isUndefined: typeof isUndefined;
|
|
80
|
+
isUndefined: typeof import("packages/vest-utils/types/vest-utils").isUndefined;
|
|
97
81
|
isValueOf: typeof isValueOf;
|
|
98
|
-
lengthEquals: typeof lengthEquals;
|
|
82
|
+
lengthEquals: typeof import("packages/vest-utils/types/vest-utils").lengthEquals;
|
|
99
83
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
100
84
|
lessThan: typeof lessThan;
|
|
101
85
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
102
|
-
longerThan: typeof longerThan;
|
|
86
|
+
longerThan: typeof import("packages/vest-utils/types/vest-utils").longerThan;
|
|
103
87
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
104
88
|
lt: typeof lessThan;
|
|
105
89
|
lte: typeof lessThanOrEquals;
|
|
@@ -107,13 +91,13 @@ declare const baseRules: {
|
|
|
107
91
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
108
92
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
109
93
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
110
|
-
numberEquals: typeof numberEquals;
|
|
94
|
+
numberEquals: typeof import("packages/vest-utils/types/vest-utils").numberEquals;
|
|
111
95
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
112
96
|
shorterThan: typeof shorterThan;
|
|
113
97
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
114
98
|
startsWith: typeof startsWith;
|
|
115
99
|
};
|
|
116
|
-
type Rules<E =
|
|
100
|
+
type Rules<E> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
101
|
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
118
102
|
};
|
|
119
103
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|