n4s 4.1.9 → 4.2.2-dev-fcaa09
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 +1 -1
- package/dist/cjs/compose.production.js +1 -1
- package/dist/cjs/compounds.development.js +1 -1
- package/dist/cjs/compounds.production.js +1 -1
- package/dist/cjs/n4s.development.js +2 -2
- package/dist/cjs/n4s.production.js +1 -1
- package/dist/cjs/schema.development.js +1 -1
- package/dist/cjs/schema.production.js +1 -1
- package/dist/es/compose.development.js +1 -1
- package/dist/es/compose.production.js +1 -1
- package/dist/es/compounds.development.js +1 -1
- package/dist/es/compounds.production.js +1 -1
- package/dist/es/n4s.development.js +3 -3
- package/dist/es/n4s.production.js +1 -1
- package/dist/es/schema.development.js +1 -1
- package/dist/es/schema.production.js +1 -1
- package/dist/umd/compose.development.js +8 -62
- package/dist/umd/compose.production.js +1 -1
- package/dist/umd/compounds.development.js +11 -55
- package/dist/umd/compounds.production.js +1 -1
- package/dist/umd/n4s.development.js +71 -268
- package/dist/umd/n4s.production.js +1 -1
- package/dist/umd/schema.development.js +8 -61
- package/dist/umd/schema.production.js +1 -1
- package/package.json +3 -3
- package/tsconfig.json +55 -1
- package/types/compose.d.ts +16 -20
- package/types/compose.d.ts.map +1 -0
- package/types/compounds.d.ts +22 -29
- package/types/compounds.d.ts.map +1 -0
- package/types/n4s.d.ts +18 -28
- package/types/n4s.d.ts.map +1 -0
- package/types/schema.d.ts +21 -24
- package/types/schema.d.ts.map +1 -0
|
@@ -1,61 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'n4s'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s));
|
|
5
|
-
}(this, (function (exports, n4s) { 'use strict';
|
|
6
|
-
|
|
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);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function isFunction(value) {
|
|
20
|
-
return typeof value === 'function';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function optionalFunctionValue(value) {
|
|
24
|
-
var args = [];
|
|
25
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
26
|
-
args[_i - 1] = arguments[_i];
|
|
27
|
-
}
|
|
28
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function defaultTo(value, defaultValue) {
|
|
32
|
-
var _a;
|
|
33
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
34
|
-
}
|
|
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
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-utils')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'n4s', 'vest-utils'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s, global['vest-utils']));
|
|
5
|
+
}(this, (function (exports, n4s, vestUtils) { 'use strict';
|
|
59
6
|
|
|
60
7
|
function ruleReturn(pass, message) {
|
|
61
8
|
var output = { pass: pass };
|
|
@@ -71,7 +18,7 @@
|
|
|
71
18
|
return ruleReturn(true);
|
|
72
19
|
}
|
|
73
20
|
function defaultToPassing(callback) {
|
|
74
|
-
return defaultTo(callback, passing());
|
|
21
|
+
return vestUtils.defaultTo(callback, passing());
|
|
75
22
|
}
|
|
76
23
|
|
|
77
24
|
function runLazyRule(lazyRule, currentValue) {
|
|
@@ -84,7 +31,7 @@
|
|
|
84
31
|
}
|
|
85
32
|
|
|
86
33
|
function isArrayOf(inputArray, currentRule) {
|
|
87
|
-
return defaultToPassing(mapFirst(inputArray, function (currentValue, breakout, index) {
|
|
34
|
+
return defaultToPassing(vestUtils.mapFirst(inputArray, function (currentValue, breakout, index) {
|
|
88
35
|
var res = n4s.ctx.run({ value: currentValue, set: true, meta: { index: index } }, function () { return runLazyRule(currentRule, currentValue); });
|
|
89
36
|
breakout(!res.pass, res);
|
|
90
37
|
}));
|
|
@@ -110,7 +57,7 @@
|
|
|
110
57
|
}
|
|
111
58
|
|
|
112
59
|
function optional(value, ruleChain) {
|
|
113
|
-
if (isNullish(value)) {
|
|
60
|
+
if (vestUtils.isNullish(value)) {
|
|
114
61
|
return passing();
|
|
115
62
|
}
|
|
116
63
|
return runLazyRule(ruleChain, value);
|
|
@@ -122,7 +69,7 @@
|
|
|
122
69
|
return baseRes;
|
|
123
70
|
}
|
|
124
71
|
for (var key in inputObject) {
|
|
125
|
-
if (!hasOwnProperty(shapeObject, key)) {
|
|
72
|
+
if (!vestUtils.hasOwnProperty(shapeObject, key)) {
|
|
126
73
|
return failing();
|
|
127
74
|
}
|
|
128
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(n
|
|
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})}));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
2
|
+
"version": "4.2.2-dev-fcaa09",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/n4s.js",
|
|
5
5
|
"types": "./types/n4s.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"release": "vx release"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"context": "^
|
|
14
|
-
"vest-utils": "^0.0.
|
|
13
|
+
"context": "^3.0.2-dev-fcaa09",
|
|
14
|
+
"vest-utils": "^0.0.3-dev-fcaa09"
|
|
15
15
|
},
|
|
16
16
|
"module": "./dist/es/n4s.production.js",
|
|
17
17
|
"exports": {
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig.json",
|
|
3
|
+
"rootDir": ".",
|
|
3
4
|
"compilerOptions": {
|
|
5
|
+
"baseUrl": ".",
|
|
4
6
|
"declarationMap": true,
|
|
5
7
|
"declarationDir": "./types",
|
|
6
|
-
"outDir": "./dist"
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"paths": {
|
|
10
|
+
"compose": ["src/exports/compose.ts"],
|
|
11
|
+
"compounds": ["src/exports/compounds.ts"],
|
|
12
|
+
"schema": ["src/exports/schema.ts"],
|
|
13
|
+
"eachEnforceRule": ["src/lib/eachEnforceRule.ts"],
|
|
14
|
+
"enforceUtilityTypes": ["src/lib/enforceUtilityTypes.ts"],
|
|
15
|
+
"isProxySupported": ["src/lib/isProxySupported.ts"],
|
|
16
|
+
"ruleReturn": ["src/lib/ruleReturn.ts"],
|
|
17
|
+
"runLazyRule": ["src/lib/runLazyRule.ts"],
|
|
18
|
+
"transformResult": ["src/lib/transformResult.ts"],
|
|
19
|
+
"n4s": ["src/n4s.ts"],
|
|
20
|
+
"allOf": ["src/plugins/compounds/allOf.ts"],
|
|
21
|
+
"anyOf": ["src/plugins/compounds/anyOf.ts"],
|
|
22
|
+
"noneOf": ["src/plugins/compounds/noneOf.ts"],
|
|
23
|
+
"oneOf": ["src/plugins/compounds/oneOf.ts"],
|
|
24
|
+
"isArrayOf": ["src/plugins/schema/isArrayOf.ts"],
|
|
25
|
+
"loose": ["src/plugins/schema/loose.ts"],
|
|
26
|
+
"optional": ["src/plugins/schema/optional.ts"],
|
|
27
|
+
"partial": ["src/plugins/schema/partial.ts"],
|
|
28
|
+
"schemaTypes": ["src/plugins/schema/schemaTypes.ts"],
|
|
29
|
+
"shape": ["src/plugins/schema/shape.ts"],
|
|
30
|
+
"endsWith": ["src/rules/endsWith.ts"],
|
|
31
|
+
"equals": ["src/rules/equals.ts"],
|
|
32
|
+
"greaterThanOrEquals": ["src/rules/greaterThanOrEquals.ts"],
|
|
33
|
+
"inside": ["src/rules/inside.ts"],
|
|
34
|
+
"isBetween": ["src/rules/isBetween.ts"],
|
|
35
|
+
"isBlank": ["src/rules/isBlank.ts"],
|
|
36
|
+
"isBoolean": ["src/rules/isBoolean.ts"],
|
|
37
|
+
"isEven": ["src/rules/isEven.ts"],
|
|
38
|
+
"isKeyOf": ["src/rules/isKeyOf.ts"],
|
|
39
|
+
"isNaN": ["src/rules/isNaN.ts"],
|
|
40
|
+
"isNegative": ["src/rules/isNegative.ts"],
|
|
41
|
+
"isNumber": ["src/rules/isNumber.ts"],
|
|
42
|
+
"isOdd": ["src/rules/isOdd.ts"],
|
|
43
|
+
"isString": ["src/rules/isString.ts"],
|
|
44
|
+
"isTruthy": ["src/rules/isTruthy.ts"],
|
|
45
|
+
"isValueOf": ["src/rules/isValueOf.ts"],
|
|
46
|
+
"lessThan": ["src/rules/lessThan.ts"],
|
|
47
|
+
"lessThanOrEquals": ["src/rules/lessThanOrEquals.ts"],
|
|
48
|
+
"longerThanOrEquals": ["src/rules/longerThanOrEquals.ts"],
|
|
49
|
+
"matches": ["src/rules/matches.ts"],
|
|
50
|
+
"ruleCondition": ["src/rules/ruleCondition.ts"],
|
|
51
|
+
"shorterThan": ["src/rules/shorterThan.ts"],
|
|
52
|
+
"shorterThanOrEquals": ["src/rules/shorterThanOrEquals.ts"],
|
|
53
|
+
"startsWith": ["src/rules/startsWith.ts"],
|
|
54
|
+
"enforce": ["src/runtime/enforce.ts"],
|
|
55
|
+
"enforceContext": ["src/runtime/enforceContext.ts"],
|
|
56
|
+
"enforceEager": ["src/runtime/enforceEager.ts"],
|
|
57
|
+
"genEnforceLazy": ["src/runtime/genEnforceLazy.ts"],
|
|
58
|
+
"rules": ["src/runtime/rules.ts"],
|
|
59
|
+
"runtimeRules": ["src/runtime/runtimeRules.ts"]
|
|
60
|
+
}
|
|
7
61
|
}
|
|
8
62
|
}
|
package/types/compose.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unknown,
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
1
|
+
import { CB, Stringable, DropFirst } from "vest-utils";
|
|
7
2
|
type RuleReturn = boolean | {
|
|
8
3
|
pass: boolean;
|
|
9
4
|
message?: Stringable;
|
|
@@ -41,16 +36,16 @@ declare const baseRules: {
|
|
|
41
36
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
42
37
|
endsWith: typeof endsWith;
|
|
43
38
|
equals: typeof equals;
|
|
44
|
-
greaterThan: typeof import("
|
|
39
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
45
40
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
46
|
-
gt: typeof import("
|
|
41
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
47
42
|
gte: typeof greaterThanOrEquals;
|
|
48
43
|
inside: typeof inside;
|
|
49
|
-
isArray: typeof import("
|
|
44
|
+
isArray: typeof import("vest-utils").isArray;
|
|
50
45
|
isBetween: typeof isBetween;
|
|
51
46
|
isBlank: typeof isBlank;
|
|
52
|
-
isBoolean: typeof import("
|
|
53
|
-
isEmpty: typeof import("
|
|
47
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
48
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
54
49
|
isEven: (value: any) => boolean;
|
|
55
50
|
isFalsy: (value: unknown) => boolean;
|
|
56
51
|
isKeyOf: typeof isKeyOf;
|
|
@@ -70,21 +65,21 @@ declare const baseRules: {
|
|
|
70
65
|
isNotString: (v: unknown) => boolean;
|
|
71
66
|
isNotUndefined: (value?: unknown) => boolean;
|
|
72
67
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
73
|
-
isNull: typeof import("
|
|
74
|
-
isNullish: typeof import("
|
|
68
|
+
isNull: typeof import("vest-utils").isNull;
|
|
69
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
75
70
|
isNumber: typeof isNumber;
|
|
76
|
-
isNumeric: typeof import("
|
|
71
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
77
72
|
isOdd: (value: any) => boolean;
|
|
78
|
-
isPositive: typeof import("
|
|
79
|
-
isString: typeof import("
|
|
73
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
74
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
80
75
|
isTruthy: typeof isTruthy;
|
|
81
|
-
isUndefined: typeof import("
|
|
76
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
82
77
|
isValueOf: typeof isValueOf;
|
|
83
|
-
lengthEquals: typeof import("
|
|
78
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
84
79
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
85
80
|
lessThan: typeof lessThan;
|
|
86
81
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
87
|
-
longerThan: typeof import("
|
|
82
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
88
83
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
89
84
|
lt: typeof lessThan;
|
|
90
85
|
lte: typeof lessThanOrEquals;
|
|
@@ -92,7 +87,7 @@ declare const baseRules: {
|
|
|
92
87
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
93
88
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
94
89
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
95
|
-
numberEquals: typeof import("
|
|
90
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
96
91
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
97
92
|
shorterThan: typeof shorterThan;
|
|
98
93
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
@@ -124,3 +119,4 @@ type ComposeResult = LazyRuleRunners & ((value: any) => void);
|
|
|
124
119
|
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
125
120
|
declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
|
|
126
121
|
export { compose as default };
|
|
122
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/exports/compose.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/eachEnforceRule.ts","../src/runtime/enforceContext.ts","../src/lib/isProxySupported.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,iBAAwB,OAAO,CAC7B,GAAG,UAAU,EAAE,eAAe,EAAE,GAC/B,aAAa,CAoCf"}
|
package/types/compounds.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
1
|
+
import { CB, DropFirst, Stringable } from "vest-utils";
|
|
2
|
+
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
7
3
|
type RuleReturn = boolean | {
|
|
8
4
|
pass: boolean;
|
|
9
5
|
message?: Stringable;
|
|
@@ -41,16 +37,16 @@ declare const baseRules: {
|
|
|
41
37
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
42
38
|
endsWith: typeof endsWith;
|
|
43
39
|
equals: typeof equals;
|
|
44
|
-
greaterThan: typeof import("
|
|
40
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
45
41
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
46
|
-
gt: typeof import("
|
|
42
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
47
43
|
gte: typeof greaterThanOrEquals;
|
|
48
44
|
inside: typeof inside;
|
|
49
|
-
isArray: typeof import("
|
|
45
|
+
isArray: typeof import("vest-utils").isArray;
|
|
50
46
|
isBetween: typeof isBetween;
|
|
51
47
|
isBlank: typeof isBlank;
|
|
52
|
-
isBoolean: typeof import("
|
|
53
|
-
isEmpty: typeof import("
|
|
48
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
49
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
54
50
|
isEven: (value: any) => boolean;
|
|
55
51
|
isFalsy: (value: unknown) => boolean;
|
|
56
52
|
isKeyOf: typeof isKeyOf;
|
|
@@ -70,21 +66,21 @@ declare const baseRules: {
|
|
|
70
66
|
isNotString: (v: unknown) => boolean;
|
|
71
67
|
isNotUndefined: (value?: unknown) => boolean;
|
|
72
68
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
73
|
-
isNull: typeof import("
|
|
74
|
-
isNullish: typeof import("
|
|
69
|
+
isNull: typeof import("vest-utils").isNull;
|
|
70
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
75
71
|
isNumber: typeof isNumber;
|
|
76
|
-
isNumeric: typeof import("
|
|
72
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
77
73
|
isOdd: (value: any) => boolean;
|
|
78
|
-
isPositive: typeof import("
|
|
79
|
-
isString: typeof import("
|
|
74
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
75
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
80
76
|
isTruthy: typeof isTruthy;
|
|
81
|
-
isUndefined: typeof import("
|
|
77
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
82
78
|
isValueOf: typeof isValueOf;
|
|
83
|
-
lengthEquals: typeof import("
|
|
79
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
84
80
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
85
81
|
lessThan: typeof lessThan;
|
|
86
82
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
87
|
-
longerThan: typeof import("
|
|
83
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
88
84
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
89
85
|
lt: typeof lessThan;
|
|
90
86
|
lte: typeof lessThanOrEquals;
|
|
@@ -92,7 +88,7 @@ declare const baseRules: {
|
|
|
92
88
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
93
89
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
94
90
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
95
|
-
numberEquals: typeof import("
|
|
91
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
96
92
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
97
93
|
shorterThan: typeof shorterThan;
|
|
98
94
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
@@ -121,18 +117,15 @@ type LazyRuleRunners = {
|
|
|
121
117
|
run: (value: unknown) => RuleDetailedResult;
|
|
122
118
|
};
|
|
123
119
|
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
124
|
-
|
|
125
|
-
declare function anyOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
126
|
-
declare function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
127
|
-
declare function oneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
120
|
+
type EnforceCompoundRule = (value: unknown, ...rules: Lazy[]) => RuleDetailedResult;
|
|
128
121
|
declare global {
|
|
129
122
|
namespace n4s {
|
|
130
123
|
interface EnforceCustomMatchers<R> {
|
|
131
|
-
allOf:
|
|
132
|
-
anyOf:
|
|
133
|
-
noneOf:
|
|
134
|
-
oneOf:
|
|
124
|
+
allOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
125
|
+
anyOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
126
|
+
noneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
127
|
+
oneOf: EnforceCustomMatcher<EnforceCompoundRule, R>;
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
130
|
}
|
|
138
|
-
|
|
131
|
+
//# sourceMappingURL=compounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../src/exports/compounds.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/eachEnforceRule.ts","../src/runtime/enforceContext.ts","../src/lib/isProxySupported.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts","../src/plugins/compounds/allOf.ts","../src/plugins/compounds/anyOf.ts","../src/lib/enforceUtilityTypes.ts","../src/plugins/compounds/noneOf.ts","../src/plugins/compounds/oneOf.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,OAAO,EACd,GAAG,KAAK,EAAE,IAAI,EAAE,KACb,kBAAkB,CAAC;AAGxB,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACpD,MAAM,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACrD,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;SACrD;KACF;CACF"}
|
package/types/n4s.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
bind: <Fn extends (...args: any[]) => any>(ctxRef: Partial<CTXType>, fn: Fn) => Fn;
|
|
4
|
-
use: () => CTXType | undefined;
|
|
5
|
-
useX: (errorMessage?: string | undefined) => CTXType;
|
|
6
|
-
};
|
|
1
|
+
import { Stringable, DropFirst, CB } from "vest-utils";
|
|
2
|
+
declare const ctx: import("context").CtxCascadeApi<CTXType>;
|
|
7
3
|
type CTXType = {
|
|
8
4
|
meta: Record<string, any>;
|
|
9
5
|
value: any;
|
|
@@ -15,12 +11,6 @@ type EnforceContext = null | {
|
|
|
15
11
|
value: any;
|
|
16
12
|
parent: () => EnforceContext;
|
|
17
13
|
};
|
|
18
|
-
type DropFirst<T extends unknown[]> = T extends [
|
|
19
|
-
unknown,
|
|
20
|
-
...infer U
|
|
21
|
-
] ? U : never;
|
|
22
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
23
|
-
type CB = (...args: any[]) => any;
|
|
24
14
|
type RuleReturn = boolean | {
|
|
25
15
|
pass: boolean;
|
|
26
16
|
message?: Stringable;
|
|
@@ -61,16 +51,16 @@ declare const baseRules: {
|
|
|
61
51
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
62
52
|
endsWith: typeof endsWith;
|
|
63
53
|
equals: typeof equals;
|
|
64
|
-
greaterThan: typeof import("
|
|
54
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
65
55
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
66
|
-
gt: typeof import("
|
|
56
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
67
57
|
gte: typeof greaterThanOrEquals;
|
|
68
58
|
inside: typeof inside;
|
|
69
|
-
isArray: typeof import("
|
|
59
|
+
isArray: typeof import("vest-utils").isArray;
|
|
70
60
|
isBetween: typeof isBetween;
|
|
71
61
|
isBlank: typeof isBlank;
|
|
72
|
-
isBoolean: typeof import("
|
|
73
|
-
isEmpty: typeof import("
|
|
62
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
63
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
74
64
|
isEven: (value: any) => boolean;
|
|
75
65
|
isFalsy: (value: unknown) => boolean;
|
|
76
66
|
isKeyOf: typeof isKeyOf;
|
|
@@ -90,21 +80,21 @@ declare const baseRules: {
|
|
|
90
80
|
isNotString: (v: unknown) => boolean;
|
|
91
81
|
isNotUndefined: (value?: unknown) => boolean;
|
|
92
82
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
93
|
-
isNull: typeof import("
|
|
94
|
-
isNullish: typeof import("
|
|
83
|
+
isNull: typeof import("vest-utils").isNull;
|
|
84
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
95
85
|
isNumber: typeof isNumber;
|
|
96
|
-
isNumeric: typeof import("
|
|
86
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
97
87
|
isOdd: (value: any) => boolean;
|
|
98
|
-
isPositive: typeof import("
|
|
99
|
-
isString: typeof import("
|
|
88
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
89
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
100
90
|
isTruthy: typeof isTruthy;
|
|
101
|
-
isUndefined: typeof import("
|
|
91
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
102
92
|
isValueOf: typeof isValueOf;
|
|
103
|
-
lengthEquals: typeof import("
|
|
93
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
104
94
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
105
95
|
lessThan: typeof lessThan;
|
|
106
96
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
107
|
-
longerThan: typeof import("
|
|
97
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
108
98
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
109
99
|
lt: typeof lessThan;
|
|
110
100
|
lte: typeof lessThanOrEquals;
|
|
@@ -112,7 +102,7 @@ declare const baseRules: {
|
|
|
112
102
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
113
103
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
114
104
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
115
|
-
numberEquals: typeof import("
|
|
105
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
116
106
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
117
107
|
shorterThan: typeof shorterThan;
|
|
118
108
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
@@ -129,8 +119,7 @@ declare global {
|
|
|
129
119
|
}
|
|
130
120
|
}
|
|
131
121
|
type IRules = n4s.IRules<Record<string, any>>;
|
|
132
|
-
|
|
133
|
-
type EnforceEager = typeof enforceEager;
|
|
122
|
+
type EnforceEager = (value: RuleValue) => IRules;
|
|
134
123
|
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
135
124
|
type Lazy = LazyRules & LazyRuleMethods &
|
|
136
125
|
// This is a "catch all" hack to make TS happy while not
|
|
@@ -157,3 +146,4 @@ declare global {
|
|
|
157
146
|
}
|
|
158
147
|
}
|
|
159
148
|
export { enforce, ctx };
|
|
149
|
+
//# sourceMappingURL=n4s.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n4s.d.ts","sourceRoot":"","sources":["../src/n4s.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/eachEnforceRule.ts","../src/runtime/enforceContext.ts","../src/lib/isProxySupported.ts","../src/lib/transformResult.ts","../src/runtime/enforceEager.ts","../src/runtime/genEnforceLazy.ts","../src/runtime/enforce.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;SAAI;KACtC;CACF;AARD,OAAO,gBAAW,CAAgB"}
|
package/types/schema.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
...infer U
|
|
4
|
-
] ? U : never;
|
|
5
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
-
type CB = (...args: any[]) => any;
|
|
1
|
+
import { CB, DropFirst, Stringable } from "vest-utils";
|
|
2
|
+
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
7
3
|
type RuleReturn = boolean | {
|
|
8
4
|
pass: boolean;
|
|
9
5
|
message?: Stringable;
|
|
@@ -41,16 +37,16 @@ declare const baseRules: {
|
|
|
41
37
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
42
38
|
endsWith: typeof endsWith;
|
|
43
39
|
equals: typeof equals;
|
|
44
|
-
greaterThan: typeof import("
|
|
40
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
45
41
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
46
|
-
gt: typeof import("
|
|
42
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
47
43
|
gte: typeof greaterThanOrEquals;
|
|
48
44
|
inside: typeof inside;
|
|
49
|
-
isArray: typeof import("
|
|
45
|
+
isArray: typeof import("vest-utils").isArray;
|
|
50
46
|
isBetween: typeof isBetween;
|
|
51
47
|
isBlank: typeof isBlank;
|
|
52
|
-
isBoolean: typeof import("
|
|
53
|
-
isEmpty: typeof import("
|
|
48
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
49
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
54
50
|
isEven: (value: any) => boolean;
|
|
55
51
|
isFalsy: (value: unknown) => boolean;
|
|
56
52
|
isKeyOf: typeof isKeyOf;
|
|
@@ -70,21 +66,21 @@ declare const baseRules: {
|
|
|
70
66
|
isNotString: (v: unknown) => boolean;
|
|
71
67
|
isNotUndefined: (value?: unknown) => boolean;
|
|
72
68
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
73
|
-
isNull: typeof import("
|
|
74
|
-
isNullish: typeof import("
|
|
69
|
+
isNull: typeof import("vest-utils").isNull;
|
|
70
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
75
71
|
isNumber: typeof isNumber;
|
|
76
|
-
isNumeric: typeof import("
|
|
72
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
77
73
|
isOdd: (value: any) => boolean;
|
|
78
|
-
isPositive: typeof import("
|
|
79
|
-
isString: typeof import("
|
|
74
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
75
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
80
76
|
isTruthy: typeof isTruthy;
|
|
81
|
-
isUndefined: typeof import("
|
|
77
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
82
78
|
isValueOf: typeof isValueOf;
|
|
83
|
-
lengthEquals: typeof import("
|
|
79
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
84
80
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
85
81
|
lessThan: typeof lessThan;
|
|
86
82
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
87
|
-
longerThan: typeof import("
|
|
83
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
88
84
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
89
85
|
lt: typeof lessThan;
|
|
90
86
|
lte: typeof lessThanOrEquals;
|
|
@@ -92,7 +88,7 @@ declare const baseRules: {
|
|
|
92
88
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
93
89
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
94
90
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
95
|
-
numberEquals: typeof import("
|
|
91
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
96
92
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
97
93
|
shorterThan: typeof shorterThan;
|
|
98
94
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
@@ -133,11 +129,12 @@ declare function partial<T extends Record<any, any>>(shapeObject: T): T;
|
|
|
133
129
|
declare global {
|
|
134
130
|
namespace n4s {
|
|
135
131
|
interface EnforceCustomMatchers<R> {
|
|
136
|
-
isArrayOf:
|
|
137
|
-
loose:
|
|
138
|
-
shape:
|
|
139
|
-
optional:
|
|
132
|
+
isArrayOf: EnforceCustomMatcher<typeof isArrayOf, R>;
|
|
133
|
+
loose: EnforceCustomMatcher<typeof loose, R>;
|
|
134
|
+
shape: EnforceCustomMatcher<typeof shape, R>;
|
|
135
|
+
optional: EnforceCustomMatcher<typeof optional, R>;
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
138
|
}
|
|
143
139
|
export { partial };
|
|
140
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/exports/schema.ts","../src/lib/enforceUtilityTypes.ts","../src/lib/ruleReturn.ts","../src/rules/endsWith.ts","../src/rules/equals.ts","../src/rules/greaterThanOrEquals.ts","../src/rules/inside.ts","../src/rules/lessThan.ts","../src/rules/lessThanOrEquals.ts","../src/rules/isBetween.ts","../src/rules/isBlank.ts","../src/rules/isBoolean.ts","../src/rules/isEven.ts","../src/rules/isKeyOf.ts","../src/rules/isNaN.ts","../src/rules/isNegative.ts","../src/rules/isNumber.ts","../src/rules/isOdd.ts","../src/rules/isString.ts","../src/rules/isTruthy.ts","../src/rules/isValueOf.ts","../src/rules/longerThanOrEquals.ts","../src/rules/matches.ts","../src/rules/ruleCondition.ts","../src/rules/shorterThan.ts","../src/rules/shorterThanOrEquals.ts","../src/rules/startsWith.ts","../src/runtime/rules.ts","../src/runtime/runtimeRules.ts","../src/lib/eachEnforceRule.ts","../src/runtime/enforceContext.ts","../src/lib/isProxySupported.ts","../src/lib/transformResult.ts","../src/runtime/genEnforceLazy.ts","../src/lib/runLazyRule.ts","../src/plugins/schema/isArrayOf.ts","../src/plugins/schema/schemaTypes.ts","../src/plugins/schema/loose.ts","../src/plugins/schema/optional.ts","../src/plugins/schema/shape.ts","../src/plugins/schema/partial.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,QAAQ,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,qBAAqB,CAAC,CAAC;YAC/B,SAAS,EAAE,oBAAoB,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC;YACrD,KAAK,EAAE,oBAAoB,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7C,KAAK,EAAE,oBAAoB,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7C,QAAQ,EAAE,oBAAoB,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;SACpD;KACF;CACF;AAdD,OAAO,WAAW,CAAgB"}
|