-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
57 lines (44 loc) · 1.07 KB
/
types.d.ts
File metadata and controls
57 lines (44 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Ref } from 'vue-demi';
export interface UseValidation<S, V> {
setValues: (values: V) => V;
setErrors: (errors: any) => ValidationGroup; // TODO update any to JSON error
form: ValidationGroup
}
// Schema types
// ----------------------
export type ValidationSchema = SchemaRules | SchemaValues;
interface SchemaRules {
[fieldName: string]: Record<string, Validator>;
}
interface SchemaValues {
[fieldName: string]: {
value: any;
rules: Record<string, Validator>;
}
}
export interface Validator {
$validator: (value: any, context?) => boolean;
$message: string;
}
// Form validation types
// ----------------------
export interface ValidationField {
$model: Ref<any>;
$dirty: Ref<boolean>;
$invalid: Ref<boolean>;
$error: Ref<boolean>;
$errors: Ref<ValidationError[]>;
}
interface ValidationMeta {
$dirty: boolean;
$invalid: boolean;
$errors: Array<any>;
}
interface ValidationError {
$property: any;
$validator: string;
$message: string;
}
export type ValidationGroup =
Record<string, ValidationField> &
ValidationMeta;