valgen 5.1.0 → 5.2.0
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/CHANGELOG.md +7 -0
- package/cjs/core/context.js +1 -8
- package/esm/core/context.js +1 -8
- package/package.json +1 -1
- package/typings/core/context.d.ts +1 -0
- package/typings/core/types.d.ts +1 -0
- package/typings/core/validator.d.ts +1 -1
- package/typings/rules/is-tuple.d.ts +1 -1
- package/typings/rules/pipe.d.ts +2 -2
package/CHANGELOG.md
CHANGED
package/cjs/core/context.js
CHANGED
|
@@ -9,14 +9,7 @@ const OPTIONAL_VAR_PATTERN = /^([^?]+)(?:\||(.*))?$/;
|
|
|
9
9
|
class Context {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
this.errors = [];
|
|
12
|
-
|
|
13
|
-
this.maxErrors = options.maxErrors;
|
|
14
|
-
if (typeof options?.onFail === 'function')
|
|
15
|
-
this.onFail = options.onFail;
|
|
16
|
-
if (options?.coerce != null)
|
|
17
|
-
this.coerce = options?.coerce;
|
|
18
|
-
if (options?.label != null)
|
|
19
|
-
this.label = options?.label;
|
|
12
|
+
Object.assign(this, options);
|
|
20
13
|
}
|
|
21
14
|
fail(rule, message, value, details) {
|
|
22
15
|
const issue = (0, omit_undefined_js_1.omitUndefined)({
|
package/esm/core/context.js
CHANGED
|
@@ -6,14 +6,7 @@ const OPTIONAL_VAR_PATTERN = /^([^?]+)(?:\||(.*))?$/;
|
|
|
6
6
|
export class Context {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.errors = [];
|
|
9
|
-
|
|
10
|
-
this.maxErrors = options.maxErrors;
|
|
11
|
-
if (typeof options?.onFail === 'function')
|
|
12
|
-
this.onFail = options.onFail;
|
|
13
|
-
if (options?.coerce != null)
|
|
14
|
-
this.coerce = options?.coerce;
|
|
15
|
-
if (options?.label != null)
|
|
16
|
-
this.label = options?.label;
|
|
9
|
+
Object.assign(this, options);
|
|
17
10
|
}
|
|
18
11
|
fail(rule, message, value, details) {
|
|
19
12
|
const issue = omitUndefined({
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ export declare class Context implements ExecutionOptions {
|
|
|
12
12
|
property?: string;
|
|
13
13
|
index?: number;
|
|
14
14
|
label?: string;
|
|
15
|
+
[key: string]: any;
|
|
15
16
|
constructor(options?: ExecutionOptions);
|
|
16
17
|
fail(rule: Validator, message: string | Error, value: any, details?: Record<string, any>): void;
|
|
17
18
|
extend(options?: ExecutionOptions): Context;
|
package/typings/core/types.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export interface Validator<T = any, I = any, O extends ExecutionOptions = Execut
|
|
|
15
15
|
}
|
|
16
16
|
export declare function validator<T, I = T, O extends ExecutionOptions = ExecutionOptions>(fn: ValidateFunction<T, I>, validatorOptions?: ValidationOptions): Validator<T, I, O>;
|
|
17
17
|
export declare function validator<T, I = T, O extends ExecutionOptions = ExecutionOptions>(id: string, fn: ValidateFunction<T, I>, validatorOptions?: ValidationOptions): Validator<T, I, O>;
|
|
18
|
-
export declare function isValidator(x: any): x is Validator
|
|
18
|
+
export declare function isValidator(x: any): x is Validator;
|
|
@@ -23,5 +23,5 @@ export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4, T5, I5, T6, I6>(
|
|
|
23
23
|
Validator<T4, I4>,
|
|
24
24
|
Validator<T5, I5>,
|
|
25
25
|
Validator<T6, I6>,
|
|
26
|
-
...Validator
|
|
26
|
+
...Validator[]
|
|
27
27
|
], options?: ValidationOptions): Validator<[T1, T2, T3, T4, T5, T6, ...any[]], [I1, I2, I3, I4, I5, I5, ...any[]]>;
|
package/typings/rules/pipe.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { Validator } from '../core/index.js';
|
|
|
3
3
|
*
|
|
4
4
|
* @validator pipe
|
|
5
5
|
*/
|
|
6
|
-
export declare function pipe<T>(...rules: [...Validator
|
|
6
|
+
export declare function pipe<T>(...rules: [...Validator[], Validator<T, any>]): Validator<T, any, import("../core/types.js").ExecutionOptions>;
|
|
7
7
|
/**
|
|
8
8
|
* Test given value against to all codecs and returns original input
|
|
9
9
|
* @validator allOf
|
|
10
10
|
*/
|
|
11
|
-
export declare function allOf(...rules: Validator
|
|
11
|
+
export declare function allOf(...rules: Validator[]): Validator<any, any, import("../core/types.js").ExecutionOptions>;
|