n4s 5.0.0-dev-781e21 → 5.0.0-dev-ae6b14
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/README.md +2 -0
- package/dist/cjs/compose.development.js +9 -13
- package/dist/cjs/compose.production.js +1 -1
- package/dist/cjs/compounds.development.js +16 -32
- package/dist/cjs/compounds.production.js +1 -1
- package/dist/cjs/n4s.development.js +137 -213
- package/dist/cjs/n4s.production.js +1 -1
- package/dist/cjs/schema.development.js +13 -22
- package/dist/cjs/schema.production.js +1 -1
- package/dist/es/compose.development.js +11 -15
- package/dist/es/compose.production.js +1 -1
- package/dist/es/compounds.development.js +16 -32
- package/dist/es/compounds.production.js +1 -1
- package/dist/es/n4s.development.js +158 -232
- package/dist/es/n4s.production.js +1 -1
- package/dist/es/schema.development.js +13 -20
- package/dist/es/schema.production.js +1 -1
- package/dist/umd/compose.development.js +12 -16
- package/dist/umd/compose.production.js +1 -1
- package/dist/umd/compounds.development.js +19 -35
- package/dist/umd/compounds.production.js +1 -1
- package/dist/umd/n4s.development.js +140 -216
- package/dist/umd/n4s.production.js +1 -1
- package/dist/umd/schema.development.js +16 -25
- package/dist/umd/schema.production.js +1 -1
- package/package.json +62 -55
- package/testUtils/TEnforceMock.ts +3 -0
- package/types/compose.d.ts +17 -21
- package/types/compose.d.ts.map +1 -0
- package/types/compounds.d.ts +17 -22
- package/types/compounds.d.ts.map +1 -0
- package/types/n4s.d.ts +22 -22
- package/types/n4s.d.ts.map +1 -0
- package/types/schema.d.ts +17 -21
- package/types/schema.d.ts.map +1 -0
- package/tsconfig.json +0 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-utils')) :
|
|
3
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[
|
|
5
|
-
}(this, (function (exports, n4s, vestUtils) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.schema = {}, global.n4s, global["vest-utils"]));
|
|
5
|
+
})(this, (function (exports, n4s, vestUtils) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function ruleReturn(pass, message) {
|
|
8
|
-
|
|
8
|
+
const output = { pass };
|
|
9
9
|
if (message) {
|
|
10
10
|
output.message = message;
|
|
11
11
|
}
|
|
@@ -31,27 +31,20 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function isArrayOf(inputArray, currentRule) {
|
|
34
|
-
return defaultToPassing(vestUtils.mapFirst(inputArray,
|
|
35
|
-
|
|
34
|
+
return defaultToPassing(vestUtils.mapFirst(inputArray, (currentValue, breakout, index) => {
|
|
35
|
+
const res = n4s.ctx.run({ value: currentValue, set: true, meta: { index } }, () => runLazyRule(currentRule, currentValue));
|
|
36
36
|
breakout(!res.pass, res);
|
|
37
37
|
}));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function loose(inputObject, shapeObject) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return runLazyRule(currentRule, currentValue);
|
|
46
|
-
});
|
|
41
|
+
for (const key in shapeObject) {
|
|
42
|
+
const currentValue = inputObject[key];
|
|
43
|
+
const currentRule = shapeObject[key];
|
|
44
|
+
const res = n4s.ctx.run({ value: currentValue, set: true, meta: { key } }, () => runLazyRule(currentRule, currentValue));
|
|
47
45
|
if (!res.pass) {
|
|
48
|
-
return
|
|
46
|
+
return res;
|
|
49
47
|
}
|
|
50
|
-
};
|
|
51
|
-
for (var key in shapeObject) {
|
|
52
|
-
var state_1 = _loop_1(key);
|
|
53
|
-
if (typeof state_1 === "object")
|
|
54
|
-
return state_1.value;
|
|
55
48
|
}
|
|
56
49
|
return passing();
|
|
57
50
|
}
|
|
@@ -64,11 +57,11 @@
|
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
function shape(inputObject, shapeObject) {
|
|
67
|
-
|
|
60
|
+
const baseRes = loose(inputObject, shapeObject);
|
|
68
61
|
if (!baseRes.pass) {
|
|
69
62
|
return baseRes;
|
|
70
63
|
}
|
|
71
|
-
for (
|
|
64
|
+
for (const key in inputObject) {
|
|
72
65
|
if (!vestUtils.hasOwnProperty(shapeObject, key)) {
|
|
73
66
|
return failing();
|
|
74
67
|
}
|
|
@@ -79,17 +72,15 @@
|
|
|
79
72
|
// Help needed improving the typings of this file.
|
|
80
73
|
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
81
74
|
function partial(shapeObject) {
|
|
82
|
-
|
|
83
|
-
for (
|
|
75
|
+
const output = {};
|
|
76
|
+
for (const key in shapeObject) {
|
|
84
77
|
output[key] = n4s.enforce.optional(shapeObject[key]);
|
|
85
78
|
}
|
|
86
79
|
return output;
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
n4s.enforce.extend({ isArrayOf
|
|
82
|
+
n4s.enforce.extend({ isArrayOf, loose, optional, shape });
|
|
90
83
|
|
|
91
84
|
exports.partial = partial;
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})));
|
|
86
|
+
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","n4s","vest-utils"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).schema={},n.n4s,n["vest-utils"])}(this,(function(n,t,e){"use strict";function r(n,t){const e={pass:n};return t&&(e.message=t),e}function s(){return r(!1)}function o(){return r(!0)}function u(n,t){try{return n.run(t)}catch(n){return s()}}function i(n,e){for(const r in e){const s=n[r],o=e[r],i=t.ctx.run({value:s,set:!0,meta:{key:r}},(()=>u(o,s)));if(!i.pass)return i}return o()}t.enforce.extend({isArrayOf:function(n,r){return s=e.mapFirst(n,((n,e,s)=>{const o=t.ctx.run({value:n,set:!0,meta:{index:s}},(()=>u(r,n)));e(!o.pass,o)})),e.defaultTo(s,o());var s},loose:i,optional:function(n,t){return e.isNullish(n)?o():u(t,n)},shape:function(n,t){const r=i(n,t);if(!r.pass)return r;for(const r in n)if(!e.hasOwnProperty(t,r))return s();return o()}}),n.partial=function(n){const e={};for(const r in n)e[r]=t.enforce.optional(n[r]);return e}}));
|
package/package.json
CHANGED
|
@@ -1,49 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.0-dev-
|
|
2
|
+
"version": "5.0.0-dev-ae6b14",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/n4s.js",
|
|
5
5
|
"types": "./types/n4s.d.ts",
|
|
6
6
|
"name": "n4s",
|
|
7
7
|
"author": "ealush",
|
|
8
|
+
"description": "Assertion library for form validations",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vest",
|
|
11
|
+
"enforce",
|
|
12
|
+
"n4s",
|
|
13
|
+
"validation"
|
|
14
|
+
],
|
|
8
15
|
"scripts": {
|
|
9
16
|
"test": "vx test",
|
|
10
17
|
"release": "vx release"
|
|
11
18
|
},
|
|
12
19
|
"dependencies": {
|
|
13
|
-
"context": "
|
|
14
|
-
"vest-utils": "
|
|
20
|
+
"context": "3.0.9-dev-ae6b14",
|
|
21
|
+
"vest-utils": "1.0.0-dev-ae6b14"
|
|
15
22
|
},
|
|
16
23
|
"module": "./dist/es/n4s.production.js",
|
|
17
24
|
"exports": {
|
|
18
|
-
"./
|
|
25
|
+
"./schema": {
|
|
19
26
|
"production": {
|
|
20
|
-
"types": "./types/
|
|
21
|
-
"browser": "./dist/es/
|
|
22
|
-
"umd": "./dist/umd/
|
|
23
|
-
"import": "./dist/es/
|
|
24
|
-
"require": "./dist/cjs/
|
|
25
|
-
"node": "./dist/cjs/
|
|
26
|
-
"module": "./dist/es/
|
|
27
|
-
"default": "./dist/cjs/
|
|
27
|
+
"types": "./types/schema.d.ts",
|
|
28
|
+
"browser": "./dist/es/schema.production.js",
|
|
29
|
+
"umd": "./dist/umd/schema.production.js",
|
|
30
|
+
"import": "./dist/es/schema.production.js",
|
|
31
|
+
"require": "./dist/cjs/schema.production.js",
|
|
32
|
+
"node": "./dist/cjs/schema.production.js",
|
|
33
|
+
"module": "./dist/es/schema.production.js",
|
|
34
|
+
"default": "./dist/cjs/schema.production.js"
|
|
28
35
|
},
|
|
29
36
|
"development": {
|
|
30
|
-
"types": "./types/
|
|
31
|
-
"browser": "./dist/es/
|
|
32
|
-
"umd": "./dist/umd/
|
|
33
|
-
"import": "./dist/es/
|
|
34
|
-
"require": "./dist/cjs/
|
|
35
|
-
"node": "./dist/cjs/
|
|
36
|
-
"module": "./dist/es/
|
|
37
|
-
"default": "./dist/cjs/
|
|
37
|
+
"types": "./types/schema.d.ts",
|
|
38
|
+
"browser": "./dist/es/schema.development.js",
|
|
39
|
+
"umd": "./dist/umd/schema.development.js",
|
|
40
|
+
"import": "./dist/es/schema.development.js",
|
|
41
|
+
"require": "./dist/cjs/schema.development.js",
|
|
42
|
+
"node": "./dist/cjs/schema.development.js",
|
|
43
|
+
"module": "./dist/es/schema.development.js",
|
|
44
|
+
"default": "./dist/cjs/schema.development.js"
|
|
38
45
|
},
|
|
39
|
-
"types": "./types/
|
|
40
|
-
"browser": "./dist/es/
|
|
41
|
-
"umd": "./dist/umd/
|
|
42
|
-
"import": "./dist/es/
|
|
43
|
-
"require": "./dist/cjs/
|
|
44
|
-
"node": "./dist/cjs/
|
|
45
|
-
"module": "./dist/es/
|
|
46
|
-
"default": "./dist/cjs/
|
|
46
|
+
"types": "./types/schema.d.ts",
|
|
47
|
+
"browser": "./dist/es/schema.production.js",
|
|
48
|
+
"umd": "./dist/umd/schema.production.js",
|
|
49
|
+
"import": "./dist/es/schema.production.js",
|
|
50
|
+
"require": "./dist/cjs/schema.production.js",
|
|
51
|
+
"node": "./dist/cjs/schema.production.js",
|
|
52
|
+
"module": "./dist/es/schema.production.js",
|
|
53
|
+
"default": "./dist/cjs/schema.production.js"
|
|
47
54
|
},
|
|
48
55
|
"./compounds": {
|
|
49
56
|
"production": {
|
|
@@ -75,35 +82,35 @@
|
|
|
75
82
|
"module": "./dist/es/compounds.production.js",
|
|
76
83
|
"default": "./dist/cjs/compounds.production.js"
|
|
77
84
|
},
|
|
78
|
-
"./
|
|
85
|
+
"./compose": {
|
|
79
86
|
"production": {
|
|
80
|
-
"types": "./types/
|
|
81
|
-
"browser": "./dist/es/
|
|
82
|
-
"umd": "./dist/umd/
|
|
83
|
-
"import": "./dist/es/
|
|
84
|
-
"require": "./dist/cjs/
|
|
85
|
-
"node": "./dist/cjs/
|
|
86
|
-
"module": "./dist/es/
|
|
87
|
-
"default": "./dist/cjs/
|
|
87
|
+
"types": "./types/compose.d.ts",
|
|
88
|
+
"browser": "./dist/es/compose.production.js",
|
|
89
|
+
"umd": "./dist/umd/compose.production.js",
|
|
90
|
+
"import": "./dist/es/compose.production.js",
|
|
91
|
+
"require": "./dist/cjs/compose.production.js",
|
|
92
|
+
"node": "./dist/cjs/compose.production.js",
|
|
93
|
+
"module": "./dist/es/compose.production.js",
|
|
94
|
+
"default": "./dist/cjs/compose.production.js"
|
|
88
95
|
},
|
|
89
96
|
"development": {
|
|
90
|
-
"types": "./types/
|
|
91
|
-
"browser": "./dist/es/
|
|
92
|
-
"umd": "./dist/umd/
|
|
93
|
-
"import": "./dist/es/
|
|
94
|
-
"require": "./dist/cjs/
|
|
95
|
-
"node": "./dist/cjs/
|
|
96
|
-
"module": "./dist/es/
|
|
97
|
-
"default": "./dist/cjs/
|
|
97
|
+
"types": "./types/compose.d.ts",
|
|
98
|
+
"browser": "./dist/es/compose.development.js",
|
|
99
|
+
"umd": "./dist/umd/compose.development.js",
|
|
100
|
+
"import": "./dist/es/compose.development.js",
|
|
101
|
+
"require": "./dist/cjs/compose.development.js",
|
|
102
|
+
"node": "./dist/cjs/compose.development.js",
|
|
103
|
+
"module": "./dist/es/compose.development.js",
|
|
104
|
+
"default": "./dist/cjs/compose.development.js"
|
|
98
105
|
},
|
|
99
|
-
"types": "./types/
|
|
100
|
-
"browser": "./dist/es/
|
|
101
|
-
"umd": "./dist/umd/
|
|
102
|
-
"import": "./dist/es/
|
|
103
|
-
"require": "./dist/cjs/
|
|
104
|
-
"node": "./dist/cjs/
|
|
105
|
-
"module": "./dist/es/
|
|
106
|
-
"default": "./dist/cjs/
|
|
106
|
+
"types": "./types/compose.d.ts",
|
|
107
|
+
"browser": "./dist/es/compose.production.js",
|
|
108
|
+
"umd": "./dist/umd/compose.production.js",
|
|
109
|
+
"import": "./dist/es/compose.production.js",
|
|
110
|
+
"require": "./dist/cjs/compose.production.js",
|
|
111
|
+
"node": "./dist/cjs/compose.production.js",
|
|
112
|
+
"module": "./dist/es/compose.production.js",
|
|
113
|
+
"default": "./dist/cjs/compose.production.js"
|
|
107
114
|
},
|
|
108
115
|
".": {
|
|
109
116
|
"development": {
|
|
@@ -126,7 +133,7 @@
|
|
|
126
133
|
"default": "./dist/cjs/n4s.production.js"
|
|
127
134
|
},
|
|
128
135
|
"./package.json": "./package.json",
|
|
129
|
-
"
|
|
136
|
+
"./*": "./*"
|
|
130
137
|
},
|
|
131
138
|
"repository": {
|
|
132
139
|
"type": "git",
|
|
@@ -138,4 +145,4 @@
|
|
|
138
145
|
},
|
|
139
146
|
"unpkg": "./dist/umd/n4s.production.js",
|
|
140
147
|
"jsdelivr": "./dist/umd/n4s.production.js"
|
|
141
|
-
}
|
|
148
|
+
}
|
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,13 +87,13 @@ 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;
|
|
99
94
|
startsWith: typeof startsWith;
|
|
100
95
|
};
|
|
101
|
-
type Rules<E
|
|
96
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
102
97
|
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
103
98
|
};
|
|
104
99
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
@@ -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/runtime/enforceContext.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/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,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, DropFirst, Stringable } from "vest-utils";
|
|
7
2
|
type EnforceCustomMatcher<F extends CB, R> = (...args: DropFirst<Parameters<F>>) => R;
|
|
8
3
|
type RuleReturn = boolean | {
|
|
9
4
|
pass: boolean;
|
|
@@ -42,16 +37,16 @@ declare const baseRules: {
|
|
|
42
37
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
43
38
|
endsWith: typeof endsWith;
|
|
44
39
|
equals: typeof equals;
|
|
45
|
-
greaterThan: typeof import("
|
|
40
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
46
41
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
47
|
-
gt: typeof import("
|
|
42
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
48
43
|
gte: typeof greaterThanOrEquals;
|
|
49
44
|
inside: typeof inside;
|
|
50
|
-
isArray: typeof import("
|
|
45
|
+
isArray: typeof import("vest-utils").isArray;
|
|
51
46
|
isBetween: typeof isBetween;
|
|
52
47
|
isBlank: typeof isBlank;
|
|
53
|
-
isBoolean: typeof import("
|
|
54
|
-
isEmpty: typeof import("
|
|
48
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
49
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
55
50
|
isEven: (value: any) => boolean;
|
|
56
51
|
isFalsy: (value: unknown) => boolean;
|
|
57
52
|
isKeyOf: typeof isKeyOf;
|
|
@@ -71,21 +66,21 @@ declare const baseRules: {
|
|
|
71
66
|
isNotString: (v: unknown) => boolean;
|
|
72
67
|
isNotUndefined: (value?: unknown) => boolean;
|
|
73
68
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
74
|
-
isNull: typeof import("
|
|
75
|
-
isNullish: typeof import("
|
|
69
|
+
isNull: typeof import("vest-utils").isNull;
|
|
70
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
76
71
|
isNumber: typeof isNumber;
|
|
77
|
-
isNumeric: typeof import("
|
|
72
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
78
73
|
isOdd: (value: any) => boolean;
|
|
79
|
-
isPositive: typeof import("
|
|
80
|
-
isString: typeof import("
|
|
74
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
75
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
81
76
|
isTruthy: typeof isTruthy;
|
|
82
|
-
isUndefined: typeof import("
|
|
77
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
83
78
|
isValueOf: typeof isValueOf;
|
|
84
|
-
lengthEquals: typeof import("
|
|
79
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
85
80
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
86
81
|
lessThan: typeof lessThan;
|
|
87
82
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
88
|
-
longerThan: typeof import("
|
|
83
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
89
84
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
90
85
|
lt: typeof lessThan;
|
|
91
86
|
lte: typeof lessThanOrEquals;
|
|
@@ -93,13 +88,13 @@ declare const baseRules: {
|
|
|
93
88
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
94
89
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
95
90
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
96
|
-
numberEquals: typeof import("
|
|
91
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
97
92
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
98
93
|
shorterThan: typeof shorterThan;
|
|
99
94
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
100
95
|
startsWith: typeof startsWith;
|
|
101
96
|
};
|
|
102
|
-
type Rules<E
|
|
97
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
103
98
|
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
104
99
|
};
|
|
105
100
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
@@ -133,4 +128,4 @@ declare global {
|
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
130
|
}
|
|
136
|
-
|
|
131
|
+
//# sourceMappingURL=compounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compounds.d.ts","sourceRoot":"","sources":["../src/exports/compounds.ts","../src/runtime/enforceContext.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/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,3 +1,4 @@
|
|
|
1
|
+
import { DropFirst, Stringable, CB } from "vest-utils";
|
|
1
2
|
declare const ctx: import("context").CtxCascadeApi<CTXType>;
|
|
2
3
|
type CTXType = {
|
|
3
4
|
meta: Record<string, any>;
|
|
@@ -10,12 +11,6 @@ type EnforceContext = null | {
|
|
|
10
11
|
value: any;
|
|
11
12
|
parent: () => EnforceContext;
|
|
12
13
|
};
|
|
13
|
-
type DropFirst<T extends unknown[]> = T extends [
|
|
14
|
-
unknown,
|
|
15
|
-
...infer U
|
|
16
|
-
] ? U : never;
|
|
17
|
-
type Stringable = string | ((...args: any[]) => string);
|
|
18
|
-
type CB = (...args: any[]) => any;
|
|
19
14
|
type RuleReturn = boolean | {
|
|
20
15
|
pass: boolean;
|
|
21
16
|
message?: Stringable;
|
|
@@ -56,16 +51,16 @@ declare const baseRules: {
|
|
|
56
51
|
doesNotStartWith: (value: string, arg1: string) => boolean;
|
|
57
52
|
endsWith: typeof endsWith;
|
|
58
53
|
equals: typeof equals;
|
|
59
|
-
greaterThan: typeof import("
|
|
54
|
+
greaterThan: typeof import("vest-utils").greaterThan;
|
|
60
55
|
greaterThanOrEquals: typeof greaterThanOrEquals;
|
|
61
|
-
gt: typeof import("
|
|
56
|
+
gt: typeof import("vest-utils").greaterThan;
|
|
62
57
|
gte: typeof greaterThanOrEquals;
|
|
63
58
|
inside: typeof inside;
|
|
64
|
-
isArray: typeof import("
|
|
59
|
+
isArray: typeof import("vest-utils").isArray;
|
|
65
60
|
isBetween: typeof isBetween;
|
|
66
61
|
isBlank: typeof isBlank;
|
|
67
|
-
isBoolean: typeof import("
|
|
68
|
-
isEmpty: typeof import("
|
|
62
|
+
isBoolean: typeof import("vest-utils").isBoolean;
|
|
63
|
+
isEmpty: typeof import("vest-utils").isEmpty;
|
|
69
64
|
isEven: (value: any) => boolean;
|
|
70
65
|
isFalsy: (value: unknown) => boolean;
|
|
71
66
|
isKeyOf: typeof isKeyOf;
|
|
@@ -85,21 +80,21 @@ declare const baseRules: {
|
|
|
85
80
|
isNotString: (v: unknown) => boolean;
|
|
86
81
|
isNotUndefined: (value?: unknown) => boolean;
|
|
87
82
|
isNotValueOf: (value: any, objectToCheck: any) => boolean;
|
|
88
|
-
isNull: typeof import("
|
|
89
|
-
isNullish: typeof import("
|
|
83
|
+
isNull: typeof import("vest-utils").isNull;
|
|
84
|
+
isNullish: typeof import("vest-utils").isNullish;
|
|
90
85
|
isNumber: typeof isNumber;
|
|
91
|
-
isNumeric: typeof import("
|
|
86
|
+
isNumeric: typeof import("vest-utils").isNumeric;
|
|
92
87
|
isOdd: (value: any) => boolean;
|
|
93
|
-
isPositive: typeof import("
|
|
94
|
-
isString: typeof import("
|
|
88
|
+
isPositive: typeof import("vest-utils").isPositive;
|
|
89
|
+
isString: typeof import("vest-utils").isStringValue;
|
|
95
90
|
isTruthy: typeof isTruthy;
|
|
96
|
-
isUndefined: typeof import("
|
|
91
|
+
isUndefined: typeof import("vest-utils").isUndefined;
|
|
97
92
|
isValueOf: typeof isValueOf;
|
|
98
|
-
lengthEquals: typeof import("
|
|
93
|
+
lengthEquals: typeof import("vest-utils").lengthEquals;
|
|
99
94
|
lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
|
|
100
95
|
lessThan: typeof lessThan;
|
|
101
96
|
lessThanOrEquals: typeof lessThanOrEquals;
|
|
102
|
-
longerThan: typeof import("
|
|
97
|
+
longerThan: typeof import("vest-utils").longerThan;
|
|
103
98
|
longerThanOrEquals: typeof longerThanOrEquals;
|
|
104
99
|
lt: typeof lessThan;
|
|
105
100
|
lte: typeof lessThanOrEquals;
|
|
@@ -107,13 +102,13 @@ declare const baseRules: {
|
|
|
107
102
|
notEquals: (value: unknown, arg1: unknown) => boolean;
|
|
108
103
|
notInside: (value: unknown, arg1: string | unknown[]) => boolean;
|
|
109
104
|
notMatches: (value: string, regex: string | RegExp) => boolean;
|
|
110
|
-
numberEquals: typeof import("
|
|
105
|
+
numberEquals: typeof import("vest-utils").numberEquals;
|
|
111
106
|
numberNotEquals: (value: string | number, eq: string | number) => boolean;
|
|
112
107
|
shorterThan: typeof shorterThan;
|
|
113
108
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
114
109
|
startsWith: typeof startsWith;
|
|
115
110
|
};
|
|
116
|
-
type Rules<E
|
|
111
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
112
|
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
118
113
|
};
|
|
119
114
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
@@ -124,7 +119,11 @@ declare global {
|
|
|
124
119
|
}
|
|
125
120
|
}
|
|
126
121
|
type IRules = n4s.IRules<Record<string, any>>;
|
|
127
|
-
type
|
|
122
|
+
type TModifiers = {
|
|
123
|
+
message: (input: string) => EnforceEagerReturn;
|
|
124
|
+
};
|
|
125
|
+
type EnforceEagerReturn = IRules & TModifiers;
|
|
126
|
+
type EnforceEager = (value: RuleValue) => EnforceEagerReturn;
|
|
128
127
|
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
129
128
|
type Lazy = LazyRules & LazyRuleMethods &
|
|
130
129
|
// This is a "catch all" hack to make TS happy while not
|
|
@@ -151,3 +150,4 @@ declare global {
|
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
export { enforce, ctx };
|
|
153
|
+
//# sourceMappingURL=n4s.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"n4s.d.ts","sourceRoot":"","sources":["../src/n4s.ts","../src/runtime/enforceContext.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/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"}
|