n4s 4.1.1 → 4.1.4
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/compose/package.json +2 -0
- package/compounds/package.json +2 -0
- package/dist/cjs/compose.development.js +28 -60
- package/dist/cjs/compose.production.js +1 -1
- package/dist/cjs/compounds.development.js +17 -2
- package/dist/cjs/compounds.production.js +1 -1
- package/dist/cjs/n4s.development.js +46 -48
- package/dist/cjs/n4s.production.js +1 -1
- package/dist/cjs/schema.development.js +1 -1
- package/dist/es/compose.development.js +28 -60
- package/dist/es/compose.production.js +1 -1
- package/dist/es/compounds.development.js +17 -2
- package/dist/es/compounds.production.js +1 -1
- package/dist/es/n4s.development.js +46 -48
- package/dist/es/n4s.production.js +1 -1
- package/dist/es/schema.development.js +1 -1
- package/dist/umd/compose.development.js +28 -60
- package/dist/umd/compose.production.js +1 -1
- package/dist/umd/compounds.development.js +17 -2
- package/dist/umd/compounds.production.js +1 -1
- package/dist/umd/n4s.development.js +43 -45
- package/dist/umd/n4s.production.js +1 -1
- package/dist/umd/schema.development.js +1 -1
- package/package.json +5 -3
- package/schema/package.json +2 -0
- package/types/compose.d.ts +22 -21
- package/types/compounds.d.ts +24 -23
- package/types/n4s.d.ts +32 -31
- package/types/schema.d.ts +26 -25
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.1.
|
|
2
|
+
"version": "4.1.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/n4s.js",
|
|
5
5
|
"types": "./types/n4s.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"release": "vx release"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"context": "^2.0.
|
|
13
|
+
"context": "^2.0.3"
|
|
14
14
|
},
|
|
15
15
|
"module": "./dist/es/n4s.production.js",
|
|
16
16
|
"exports": {
|
|
@@ -134,5 +134,7 @@
|
|
|
134
134
|
},
|
|
135
135
|
"bugs": {
|
|
136
136
|
"url": "https://github.com/ealush/vest.git/issues"
|
|
137
|
-
}
|
|
137
|
+
},
|
|
138
|
+
"unpkg": "./dist/umd/n4s.production.js",
|
|
139
|
+
"jsdelivr": "./dist/umd/n4s.production.js"
|
|
138
140
|
}
|
package/schema/package.json
CHANGED
package/types/compose.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ type DropFirst<T extends unknown[]> = T extends [
|
|
|
2
2
|
unknown,
|
|
3
3
|
...infer U
|
|
4
4
|
] ? U : never;
|
|
5
|
-
type
|
|
6
|
-
type
|
|
5
|
+
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
+
type RuleReturn = boolean | {
|
|
7
7
|
pass: boolean;
|
|
8
|
-
message?:
|
|
8
|
+
message?: Stringable;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
10
|
+
type RuleDetailedResult = {
|
|
11
11
|
pass: boolean;
|
|
12
12
|
message?: string;
|
|
13
13
|
};
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type KBaseRules = keyof
|
|
17
|
-
declare function condition(value: any, callback: (value: any) =>
|
|
14
|
+
type Args = any[];
|
|
15
|
+
type BaseRules = typeof baseRules;
|
|
16
|
+
type KBaseRules = keyof BaseRules;
|
|
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
20
|
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
@@ -35,6 +35,7 @@ declare function isNull(value: unknown): value is null;
|
|
|
35
35
|
declare function isNullish(value: any): value is null | undefined;
|
|
36
36
|
declare function isNumber(value: unknown): value is number;
|
|
37
37
|
declare function isNumeric(value: string | number): boolean;
|
|
38
|
+
declare function isPositive(value: number | string): boolean;
|
|
38
39
|
declare function isStringValue(v: unknown): v is string;
|
|
39
40
|
declare function isTruthy(value: unknown): boolean;
|
|
40
41
|
declare function isUndefined(value?: unknown): boolean;
|
|
@@ -89,7 +90,7 @@ declare const baseRules: {
|
|
|
89
90
|
isNumber: typeof isNumber;
|
|
90
91
|
isNumeric: typeof isNumeric;
|
|
91
92
|
isOdd: (value: any) => boolean;
|
|
92
|
-
isPositive:
|
|
93
|
+
isPositive: typeof isPositive;
|
|
93
94
|
isString: typeof isStringValue;
|
|
94
95
|
isTruthy: typeof isTruthy;
|
|
95
96
|
isUndefined: typeof isUndefined;
|
|
@@ -112,29 +113,29 @@ declare const baseRules: {
|
|
|
112
113
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
113
114
|
startsWith: typeof startsWith;
|
|
114
115
|
};
|
|
115
|
-
type
|
|
116
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<
|
|
116
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
|
+
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
117
118
|
};
|
|
118
119
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
119
120
|
declare global {
|
|
120
121
|
namespace n4s {
|
|
121
|
-
interface IRules<E> extends
|
|
122
|
+
interface IRules<E> extends Rules<E> {
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
type
|
|
126
|
-
type
|
|
126
|
+
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
127
|
+
type Lazy = LazyRules & LazyRuleMethods &
|
|
127
128
|
// This is a "catch all" hack to make TS happy while not
|
|
128
129
|
// losing type hints
|
|
129
130
|
Record<string, (...args: any[]) => any>;
|
|
130
|
-
type
|
|
131
|
-
message: (message:
|
|
131
|
+
type LazyRuleMethods = LazyRuleRunners & {
|
|
132
|
+
message: (message: LazyMessage) => Lazy;
|
|
132
133
|
};
|
|
133
|
-
type
|
|
134
|
+
type LazyRuleRunners = {
|
|
134
135
|
test: (value: unknown) => boolean;
|
|
135
|
-
run: (value: unknown) =>
|
|
136
|
+
run: (value: unknown) => RuleDetailedResult;
|
|
136
137
|
};
|
|
137
|
-
type
|
|
138
|
-
type
|
|
139
|
-
declare function compose(...composites:
|
|
138
|
+
type ComposeResult = LazyRuleRunners & ((value: any) => void);
|
|
139
|
+
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
140
|
+
declare function compose(...composites: LazyRuleRunners[]): ComposeResult;
|
|
140
141
|
export { compose as default };
|
package/types/compounds.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ type DropFirst<T extends unknown[]> = T extends [
|
|
|
2
2
|
unknown,
|
|
3
3
|
...infer U
|
|
4
4
|
] ? U : never;
|
|
5
|
-
type
|
|
6
|
-
type
|
|
5
|
+
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
+
type RuleReturn = boolean | {
|
|
7
7
|
pass: boolean;
|
|
8
|
-
message?:
|
|
8
|
+
message?: Stringable;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
10
|
+
type RuleDetailedResult = {
|
|
11
11
|
pass: boolean;
|
|
12
12
|
message?: string;
|
|
13
13
|
};
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type KBaseRules = keyof
|
|
17
|
-
declare function condition(value: any, callback: (value: any) =>
|
|
14
|
+
type Args = any[];
|
|
15
|
+
type BaseRules = typeof baseRules;
|
|
16
|
+
type KBaseRules = keyof BaseRules;
|
|
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
20
|
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
@@ -35,6 +35,7 @@ declare function isNull(value: unknown): value is null;
|
|
|
35
35
|
declare function isNullish(value: any): value is null | undefined;
|
|
36
36
|
declare function isNumber(value: unknown): value is number;
|
|
37
37
|
declare function isNumeric(value: string | number): boolean;
|
|
38
|
+
declare function isPositive(value: number | string): boolean;
|
|
38
39
|
declare function isStringValue(v: unknown): v is string;
|
|
39
40
|
declare function isTruthy(value: unknown): boolean;
|
|
40
41
|
declare function isUndefined(value?: unknown): boolean;
|
|
@@ -89,7 +90,7 @@ declare const baseRules: {
|
|
|
89
90
|
isNumber: typeof isNumber;
|
|
90
91
|
isNumeric: typeof isNumeric;
|
|
91
92
|
isOdd: (value: any) => boolean;
|
|
92
|
-
isPositive:
|
|
93
|
+
isPositive: typeof isPositive;
|
|
93
94
|
isString: typeof isStringValue;
|
|
94
95
|
isTruthy: typeof isTruthy;
|
|
95
96
|
isUndefined: typeof isUndefined;
|
|
@@ -112,33 +113,33 @@ declare const baseRules: {
|
|
|
112
113
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
113
114
|
startsWith: typeof startsWith;
|
|
114
115
|
};
|
|
115
|
-
type
|
|
116
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<
|
|
116
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
|
+
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
117
118
|
};
|
|
118
119
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
119
120
|
declare global {
|
|
120
121
|
namespace n4s {
|
|
121
|
-
interface IRules<E> extends
|
|
122
|
+
interface IRules<E> extends Rules<E> {
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
type
|
|
126
|
-
type
|
|
126
|
+
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
127
|
+
type Lazy = LazyRules & LazyRuleMethods &
|
|
127
128
|
// This is a "catch all" hack to make TS happy while not
|
|
128
129
|
// losing type hints
|
|
129
130
|
Record<string, (...args: any[]) => any>;
|
|
130
|
-
type
|
|
131
|
-
message: (message:
|
|
131
|
+
type LazyRuleMethods = LazyRuleRunners & {
|
|
132
|
+
message: (message: LazyMessage) => Lazy;
|
|
132
133
|
};
|
|
133
|
-
type
|
|
134
|
+
type LazyRuleRunners = {
|
|
134
135
|
test: (value: unknown) => boolean;
|
|
135
|
-
run: (value: unknown) =>
|
|
136
|
+
run: (value: unknown) => RuleDetailedResult;
|
|
136
137
|
};
|
|
137
|
-
type
|
|
138
|
-
declare function allOf(value: unknown, ...rules:
|
|
139
|
-
declare function anyOf(value: unknown, ...rules:
|
|
140
|
-
declare function noneOf(value: unknown, ...rules:
|
|
141
|
-
declare function oneOf(value: unknown, ...rules:
|
|
138
|
+
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
139
|
+
declare function allOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
140
|
+
declare function anyOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
141
|
+
declare function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
142
|
+
declare function oneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult;
|
|
142
143
|
declare global {
|
|
143
144
|
namespace n4s {
|
|
144
145
|
interface EnforceCustomMatchers<R> {
|
package/types/n4s.d.ts
CHANGED
|
@@ -10,31 +10,31 @@ type CTXType = {
|
|
|
10
10
|
set?: boolean;
|
|
11
11
|
parent: () => CTXType | null;
|
|
12
12
|
};
|
|
13
|
-
type
|
|
13
|
+
type EnforceContext = null | {
|
|
14
14
|
meta: Record<string, any>;
|
|
15
15
|
value: any;
|
|
16
|
-
parent: () =>
|
|
16
|
+
parent: () => EnforceContext;
|
|
17
17
|
};
|
|
18
18
|
type DropFirst<T extends unknown[]> = T extends [
|
|
19
19
|
unknown,
|
|
20
20
|
...infer U
|
|
21
21
|
] ? U : never;
|
|
22
|
-
type
|
|
23
|
-
type
|
|
22
|
+
type Stringable = string | ((...args: any[]) => string);
|
|
23
|
+
type RuleReturn = boolean | {
|
|
24
24
|
pass: boolean;
|
|
25
|
-
message?:
|
|
25
|
+
message?: Stringable;
|
|
26
26
|
};
|
|
27
|
-
type
|
|
27
|
+
type RuleDetailedResult = {
|
|
28
28
|
pass: boolean;
|
|
29
29
|
message?: string;
|
|
30
30
|
};
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
type KBaseRules = keyof
|
|
37
|
-
declare function condition(value: any, callback: (value: any) =>
|
|
31
|
+
type Args = any[];
|
|
32
|
+
type RuleValue = any;
|
|
33
|
+
type RuleBase = (value: RuleValue, ...args: Args) => RuleReturn;
|
|
34
|
+
type Rule = Record<string, RuleBase>;
|
|
35
|
+
type BaseRules = typeof baseRules;
|
|
36
|
+
type KBaseRules = keyof BaseRules;
|
|
37
|
+
declare function condition(value: any, callback: (value: any) => RuleReturn): RuleReturn;
|
|
38
38
|
declare function endsWith(value: string, arg1: string): boolean;
|
|
39
39
|
declare function equals(value: unknown, arg1: unknown): boolean;
|
|
40
40
|
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
@@ -55,6 +55,7 @@ declare function isNull(value: unknown): value is null;
|
|
|
55
55
|
declare function isNullish(value: any): value is null | undefined;
|
|
56
56
|
declare function isNumber(value: unknown): value is number;
|
|
57
57
|
declare function isNumeric(value: string | number): boolean;
|
|
58
|
+
declare function isPositive(value: number | string): boolean;
|
|
58
59
|
declare function isStringValue(v: unknown): v is string;
|
|
59
60
|
declare function isTruthy(value: unknown): boolean;
|
|
60
61
|
declare function isUndefined(value?: unknown): boolean;
|
|
@@ -109,7 +110,7 @@ declare const baseRules: {
|
|
|
109
110
|
isNumber: typeof isNumber;
|
|
110
111
|
isNumeric: typeof isNumeric;
|
|
111
112
|
isOdd: (value: any) => boolean;
|
|
112
|
-
isPositive:
|
|
113
|
+
isPositive: typeof isPositive;
|
|
113
114
|
isString: typeof isStringValue;
|
|
114
115
|
isTruthy: typeof isTruthy;
|
|
115
116
|
isUndefined: typeof isUndefined;
|
|
@@ -132,37 +133,37 @@ declare const baseRules: {
|
|
|
132
133
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
133
134
|
startsWith: typeof startsWith;
|
|
134
135
|
};
|
|
135
|
-
type
|
|
136
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<
|
|
136
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
137
|
+
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
137
138
|
};
|
|
138
139
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
139
140
|
declare global {
|
|
140
141
|
namespace n4s {
|
|
141
|
-
interface IRules<E> extends
|
|
142
|
+
interface IRules<E> extends Rules<E> {
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
type IRules = n4s.IRules<Record<string, any>>;
|
|
146
|
-
declare function enforceEager(value:
|
|
147
|
-
type
|
|
148
|
-
type
|
|
149
|
-
type
|
|
147
|
+
declare function enforceEager(value: RuleValue): IRules;
|
|
148
|
+
type EnforceEager = typeof enforceEager;
|
|
149
|
+
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
150
|
+
type Lazy = LazyRules & LazyRuleMethods &
|
|
150
151
|
// This is a "catch all" hack to make TS happy while not
|
|
151
152
|
// losing type hints
|
|
152
153
|
Record<string, (...args: any[]) => any>;
|
|
153
|
-
type
|
|
154
|
-
message: (message:
|
|
154
|
+
type LazyRuleMethods = LazyRuleRunners & {
|
|
155
|
+
message: (message: LazyMessage) => Lazy;
|
|
155
156
|
};
|
|
156
|
-
type
|
|
157
|
+
type LazyRuleRunners = {
|
|
157
158
|
test: (value: unknown) => boolean;
|
|
158
|
-
run: (value: unknown) =>
|
|
159
|
+
run: (value: unknown) => RuleDetailedResult;
|
|
159
160
|
};
|
|
160
|
-
type
|
|
161
|
-
declare const enforce:
|
|
162
|
-
type
|
|
163
|
-
type
|
|
164
|
-
context: () =>
|
|
165
|
-
extend: (customRules:
|
|
161
|
+
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
162
|
+
declare const enforce: Enforce;
|
|
163
|
+
type Enforce = EnforceMethods & LazyRules & EnforceEager;
|
|
164
|
+
type EnforceMethods = {
|
|
165
|
+
context: () => EnforceContext;
|
|
166
|
+
extend: (customRules: Rule) => void;
|
|
166
167
|
};
|
|
167
168
|
declare global {
|
|
168
169
|
namespace n4s {
|
package/types/schema.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ type DropFirst<T extends unknown[]> = T extends [
|
|
|
2
2
|
unknown,
|
|
3
3
|
...infer U
|
|
4
4
|
] ? U : never;
|
|
5
|
-
type
|
|
6
|
-
type
|
|
5
|
+
type Stringable = string | ((...args: any[]) => string);
|
|
6
|
+
type RuleReturn = boolean | {
|
|
7
7
|
pass: boolean;
|
|
8
|
-
message?:
|
|
8
|
+
message?: Stringable;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
10
|
+
type RuleDetailedResult = {
|
|
11
11
|
pass: boolean;
|
|
12
12
|
message?: string;
|
|
13
13
|
};
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type KBaseRules = keyof
|
|
17
|
-
declare function condition(value: any, callback: (value: any) =>
|
|
14
|
+
type Args = any[];
|
|
15
|
+
type BaseRules = typeof baseRules;
|
|
16
|
+
type KBaseRules = keyof BaseRules;
|
|
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
20
|
declare function greaterThan(value: number | string, gt: number | string): boolean;
|
|
@@ -35,6 +35,7 @@ declare function isNull(value: unknown): value is null;
|
|
|
35
35
|
declare function isNullish(value: any): value is null | undefined;
|
|
36
36
|
declare function isNumber(value: unknown): value is number;
|
|
37
37
|
declare function isNumeric(value: string | number): boolean;
|
|
38
|
+
declare function isPositive(value: number | string): boolean;
|
|
38
39
|
declare function isStringValue(v: unknown): v is string;
|
|
39
40
|
declare function isTruthy(value: unknown): boolean;
|
|
40
41
|
declare function isUndefined(value?: unknown): boolean;
|
|
@@ -89,7 +90,7 @@ declare const baseRules: {
|
|
|
89
90
|
isNumber: typeof isNumber;
|
|
90
91
|
isNumeric: typeof isNumeric;
|
|
91
92
|
isOdd: (value: any) => boolean;
|
|
92
|
-
isPositive:
|
|
93
|
+
isPositive: typeof isPositive;
|
|
93
94
|
isString: typeof isStringValue;
|
|
94
95
|
isTruthy: typeof isTruthy;
|
|
95
96
|
isUndefined: typeof isUndefined;
|
|
@@ -112,37 +113,37 @@ declare const baseRules: {
|
|
|
112
113
|
shorterThanOrEquals: typeof shorterThanOrEquals;
|
|
113
114
|
startsWith: typeof startsWith;
|
|
114
115
|
};
|
|
115
|
-
type
|
|
116
|
-
[P in KBaseRules]: (...args: DropFirst<Parameters<
|
|
116
|
+
type Rules<E = Record<string, unknown>> = n4s.EnforceCustomMatchers<Rules<E> & E> & Record<string, (...args: Args) => Rules<E> & E> & {
|
|
117
|
+
[P in KBaseRules]: (...args: DropFirst<Parameters<BaseRules[P]>> | Args) => Rules<E> & E;
|
|
117
118
|
};
|
|
118
119
|
/* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface */
|
|
119
120
|
declare global {
|
|
120
121
|
namespace n4s {
|
|
121
|
-
interface IRules<E> extends
|
|
122
|
+
interface IRules<E> extends Rules<E> {
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
type
|
|
126
|
-
type
|
|
126
|
+
type LazyRules = n4s.IRules<LazyRuleMethods>;
|
|
127
|
+
type Lazy = LazyRules & LazyRuleMethods &
|
|
127
128
|
// This is a "catch all" hack to make TS happy while not
|
|
128
129
|
// losing type hints
|
|
129
130
|
Record<string, (...args: any[]) => any>;
|
|
130
|
-
type
|
|
131
|
-
message: (message:
|
|
131
|
+
type LazyRuleMethods = LazyRuleRunners & {
|
|
132
|
+
message: (message: LazyMessage) => Lazy;
|
|
132
133
|
};
|
|
133
|
-
type
|
|
134
|
+
type LazyRuleRunners = {
|
|
134
135
|
test: (value: unknown) => boolean;
|
|
135
|
-
run: (value: unknown) =>
|
|
136
|
+
run: (value: unknown) => RuleDetailedResult;
|
|
136
137
|
};
|
|
137
|
-
type
|
|
138
|
-
declare function isArrayOf(inputArray: any[], currentRule:
|
|
139
|
-
interface
|
|
138
|
+
type LazyMessage = string | ((value: unknown, originalMessage?: Stringable) => string);
|
|
139
|
+
declare function isArrayOf(inputArray: any[], currentRule: LazyRuleRunners): RuleDetailedResult;
|
|
140
|
+
interface ShapeObject extends Record<string, any>, Record<string, LazyRuleRunners> {
|
|
140
141
|
}
|
|
141
|
-
declare function loose(inputObject: Record<string, any>, shapeObject:
|
|
142
|
-
declare function optional(value: any, ruleChain:
|
|
143
|
-
declare function shape(inputObject: Record<string, any>, shapeObject:
|
|
142
|
+
declare function loose(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
143
|
+
declare function optional(value: any, ruleChain: Lazy): RuleDetailedResult;
|
|
144
|
+
declare function shape(inputObject: Record<string, any>, shapeObject: ShapeObject): RuleDetailedResult;
|
|
144
145
|
// Help needed improving the typings of this file.
|
|
145
|
-
// Ideally, we'd be able to extend
|
|
146
|
+
// Ideally, we'd be able to extend ShapeObject, but that's not possible.
|
|
146
147
|
declare function partial<T extends Record<any, any>>(shapeObject: T): T;
|
|
147
148
|
declare global {
|
|
148
149
|
namespace n4s {
|