@stacksjs/validation 0.67.0 → 0.68.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/dist/index.d.ts +6 -6
- package/dist/index.js +49 -49
- package/dist/is.d.ts +3 -3
- package/dist/reporter.d.ts +5 -6
- package/dist/rules.d.ts +29 -78
- package/dist/schema.d.ts +13 -15
- package/dist/validator.d.ts +10 -10
- package/package.json +1 -1
- package/dist/types/index.d.ts +0 -1
package/dist/is.d.ts
CHANGED
|
@@ -23,6 +23,6 @@ export declare function isPositive(v: any): boolean;
|
|
|
23
23
|
export declare function isNegative(v: any): boolean;
|
|
24
24
|
export declare function isEven(v: any): boolean;
|
|
25
25
|
export declare function isOdd(v: any): boolean;
|
|
26
|
-
export declare function isEvenOrOdd(v: any):
|
|
27
|
-
export declare function isPositiveOrNegative(v: any):
|
|
28
|
-
export declare function isIntegerOrFloat(v: any):
|
|
26
|
+
export declare function isEvenOrOdd(v: any): 'even' | 'odd';
|
|
27
|
+
export declare function isPositiveOrNegative(v: any): 'positive' | 'negative';
|
|
28
|
+
export declare function isIntegerOrFloat(v: any): 'integer' | 'float';
|
package/dist/reporter.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
interface MessageObject {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare interface MessageObject {
|
|
2
|
+
message: string
|
|
3
|
+
rule: string
|
|
4
|
+
field: string
|
|
5
5
|
}
|
|
6
6
|
export declare function reportError(errors: MessageObject[]): void;
|
|
7
|
-
export declare function getErrors(): MessageObject[];
|
|
8
|
-
export {};
|
|
7
|
+
export declare function getErrors(): MessageObject[];
|
package/dist/rules.d.ts
CHANGED
|
@@ -1,79 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
mutate: (newValue: any, field: FieldContext) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Report error to the error reporter
|
|
27
|
-
*/
|
|
28
|
-
report: ErrorReporterContract["report"];
|
|
29
|
-
/**
|
|
30
|
-
* Is this field valid. Default: true
|
|
31
|
-
*/
|
|
32
|
-
isValid: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Is this field has value defined.
|
|
35
|
-
*/
|
|
36
|
-
isDefined: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Wildcard path for the field. The value is a nested
|
|
39
|
-
* pointer to the field under validation.
|
|
40
|
-
*
|
|
41
|
-
* In case of arrays, the `*` wildcard is used.
|
|
42
|
-
*/
|
|
43
|
-
wildCardPath: string;
|
|
44
|
-
/**
|
|
45
|
-
* The parent property is the parent of the field. It could be an
|
|
46
|
-
* array or an object.
|
|
47
|
-
*/
|
|
48
|
-
parent: any;
|
|
49
|
-
/**
|
|
50
|
-
* Name of the field under validation. In case of an array, the field
|
|
51
|
-
* name will be a number
|
|
52
|
-
*/
|
|
53
|
-
name: string | number;
|
|
54
|
-
/**
|
|
55
|
-
* Is this field an array member
|
|
56
|
-
*/
|
|
57
|
-
isArrayMember: boolean;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Thanks to VineJS for the following types:
|
|
61
|
-
*
|
|
62
|
-
* The error reporter is used to report errors during the validation
|
|
63
|
-
* process.
|
|
64
|
-
*/
|
|
65
|
-
export interface ErrorReporterContract {
|
|
66
|
-
/**
|
|
67
|
-
* A boolean to known if there are one or more
|
|
68
|
-
* errors.
|
|
69
|
-
*/
|
|
70
|
-
hasErrors: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Creates an instance of an exception to throw
|
|
73
|
-
*/
|
|
74
|
-
createError: () => Error;
|
|
75
|
-
/**
|
|
76
|
-
* Report error for a field
|
|
77
|
-
*/
|
|
78
|
-
report: (message: string, rule: string, field: FieldContext, args?: Record<string, any>) => any;
|
|
1
|
+
export declare interface FieldContext {
|
|
2
|
+
value: unknown
|
|
3
|
+
|
|
4
|
+
data: any
|
|
5
|
+
|
|
6
|
+
meta: Record<string, any>
|
|
7
|
+
|
|
8
|
+
mutate: (newValue: any, field: FieldContext) => void
|
|
9
|
+
|
|
10
|
+
report: ErrorReporterContract['report']
|
|
11
|
+
|
|
12
|
+
isValid: boolean
|
|
13
|
+
|
|
14
|
+
isDefined: boolean
|
|
15
|
+
|
|
16
|
+
wildCardPath: string
|
|
17
|
+
|
|
18
|
+
parent: any
|
|
19
|
+
|
|
20
|
+
name: string | number
|
|
21
|
+
|
|
22
|
+
isArrayMember: boolean
|
|
79
23
|
}
|
|
24
|
+
export declare interface ErrorReporterContract {
|
|
25
|
+
hasErrors: boolean
|
|
26
|
+
|
|
27
|
+
createError: () => Error
|
|
28
|
+
|
|
29
|
+
report: (message: string, rule: string, field: FieldContext, args?: Record<string, any>) => any
|
|
30
|
+
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
type SchemaString = string
|
|
5
|
-
type SchemaNumber = number
|
|
6
|
-
type SchemaBoolean = boolean
|
|
7
|
-
type SchemaEnum = string[]
|
|
8
|
-
export type SchemaType = SchemaString | SchemaNumber | SchemaBoolean | SchemaEnum
|
|
9
|
-
export { VineBoolean, VineDate, VineEnum, VineNumber, VineString } from "@vinejs/vine";
|
|
10
|
-
export type { Infer } from "@vinejs/vine/types";
|
|
1
|
+
export { rule, schema, SimpleMessagesProvider, VineError }
|
|
2
|
+
export { VineBoolean, VineDate, VineEnum, VineNumber, VineString } from '@vinejs/vine'
|
|
3
|
+
export type { Infer } from '@vinejs/vine/types';
|
|
4
|
+
declare type SchemaString = string
|
|
5
|
+
type SchemaNumber = number
|
|
6
|
+
type SchemaBoolean = boolean
|
|
7
|
+
type SchemaEnum = string[]
|
|
8
|
+
export declare type SchemaType = SchemaString | SchemaNumber | SchemaBoolean | SchemaEnum
|
|
11
9
|
export declare const validate: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
10
|
+
string: (defaultValue: string) => SchemaString;
|
|
11
|
+
number: (defaultValue: number) => SchemaNumber;
|
|
12
|
+
boolean: (defaultValue: boolean) => SchemaBoolean;
|
|
13
|
+
enum: (values: string[]) => SchemaEnum
|
|
14
|
+
};
|
package/dist/validator.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { VineType } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { VineType } from '@stacksjs/types';
|
|
2
|
+
|
|
3
|
+
declare interface RequestData {
|
|
4
|
+
[key: string]: any
|
|
4
5
|
}
|
|
5
|
-
interface ValidationField {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
declare interface ValidationField {
|
|
7
|
+
rule: VineType
|
|
8
|
+
message: Record<string, string>
|
|
8
9
|
}
|
|
9
|
-
interface CustomAttributes {
|
|
10
|
-
|
|
10
|
+
declare interface CustomAttributes {
|
|
11
|
+
[key: string]: ValidationField
|
|
11
12
|
}
|
|
12
13
|
export declare function isObjectNotEmpty(obj: object | undefined): boolean;
|
|
13
14
|
export declare function validateField(modelFile: string, params: RequestData): Promise<any>;
|
|
14
|
-
export declare function customValidate(attributes: CustomAttributes, params: RequestData): Promise<any>;
|
|
15
|
-
export {};
|
|
15
|
+
export declare function customValidate(attributes: CustomAttributes, params: RequestData): Promise<any>;
|
package/package.json
CHANGED
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { VineBoolean as ValidationBoolean, VineEnum as ValidationEnum, VineNumber as ValidationNumber, VineString as ValidationString } from "@vinejs/vine";
|