-
-
Notifications
You must be signed in to change notification settings - Fork 503
/
index.d.ts
103 lines (93 loc) · 3.67 KB
/
index.d.ts
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import {
ValidationRuleWithoutParams,
ValidationRuleWithParams,
ValidationRule,
ValidationArgs
} from '@vuelidate/core';
import { Ref } from 'vue-demi';
// Rules
export const alpha: ValidationRuleWithoutParams;
export const alphaNum: ValidationRuleWithoutParams;
export const and: <T = unknown>(
...validators: ValidationRule<T>[]
) => ValidationRuleWithoutParams;
export const between: (
min: number | Ref<number>,
max: number | Ref<number>
) => ValidationRuleWithParams<{ min: number, max: number }>;
export const decimal: ValidationRuleWithoutParams;
export const email: ValidationRuleWithoutParams;
export const integer: ValidationRuleWithoutParams;
export const ipAddress: ValidationRuleWithoutParams;
export const macAddress: (separator: string | Ref<string>) => ValidationRuleWithoutParams;
export const maxLength: (
max: number | Ref<number>
) => ValidationRuleWithParams<{ max: number }>;
export const maxValue: (
max: number | Ref<number> | string | Ref<string> | Date | Ref<Date>
) => ValidationRuleWithParams<{ max: number }>;
export const minLength: (
min: number | Ref<number>
) => ValidationRuleWithParams<{ min: number }>;
export const minValue: (
min: number | Ref<number> | string | Ref<string> | Date | Ref<Date>
) => ValidationRuleWithParams<{ min: number }>;
export const not: <T = unknown>(validator: ValidationRule<T>) => ValidationRuleWithoutParams;
export const numeric: ValidationRuleWithoutParams;
export const or: <T = unknown>(
...validators: ValidationRule<T>[]
) => ValidationRuleWithoutParams;
export const required: ValidationRuleWithoutParams;
export const requiredIf: (prop: boolean | Ref<boolean> | string | (() => boolean | Promise<boolean>)) => ValidationRuleWithoutParams;
export const requiredUnless: (prop: boolean | Ref<boolean> | string | (() => boolean | Promise<boolean>)) => ValidationRuleWithoutParams;
export const sameAs: <E = unknown>(
equalTo: E | Ref<E>,
otherName?: string
) => ValidationRuleWithParams<{ equalTo: E, otherName: string }>;
export const url: ValidationRuleWithoutParams;
export const helpers: {
withParams: <T = unknown>(params: object, validator: ValidationRule<T>) => ValidationRuleWithParams
withMessage: <T = unknown>(message: string | ((params: MessageProps) => string), validator: ValidationRule<T>) => ValidationRuleWithParams
req: Function
len: Function
regex: Function
unwrap: Function
withAsync: Function,
forEach: (validators: ValidationArgs) => { $validator: ValidationRule, $message: () => string }
}
export function TranslationFunction(path: string, params: { model: string, property: string, [key: string]: any }): string
export function messagePathFactory(params: MessageProps): string;
export interface MessageParams {
model: unknown;
property: string;
invalid: boolean;
pending: boolean;
propertyPath: string;
response: unknown;
validator: string;
[key: string]: any;
}
export function messageParamsFactory(params: MessageParams): MessageParams;
export interface MessageProps {
$model: string;
$property: string;
$params: { [attr: string] : any };
$validator: string;
$pending: boolean;
$invalid: boolean;
$response: unknown;
$propertyPath: string;
}
export type ValidatorWrapper = (...args: any[]) => ValidationRule ;
declare function withI18nMessage <T extends (ValidationRule | ValidatorWrapper)>(
validator: T,
options?: {
withArguments?: boolean,
messagePath?: typeof messagePathFactory,
messageParams?: typeof messageParamsFactory,
}): T
export function createI18nMessage({ t, messagePath, messageParams }: {
t: typeof TranslationFunction;
messagePath?: typeof messagePathFactory;
messageParams?: typeof messageParamsFactory;
}): typeof withI18nMessage