1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | type EventValidation<T = any> = {
|
7 | ctr?: AbortController;
|
8 | data?: Partial<T>;
|
9 | parser?: (value: any) => void;
|
10 | };
|
11 |
|
12 | type UseSValidationProps<T> = {
|
13 | service?: (event?: EventValidation<T>) => any;
|
14 | data: T;
|
15 | message?: Record<string, (params: any) => string>;
|
16 | param?: {
|
17 | type: string;
|
18 | path: string;
|
19 | };
|
20 | };
|
21 |
|
22 | interface UseSValidation<T> {
|
23 | processing: boolean;
|
24 | error: (key?: keyof T) => boolean;
|
25 | message: (key: keyof T) => string;
|
26 | clear: () => void;
|
27 | cancel: () => void;
|
28 | validate: (option?: {
|
29 | service?: (event?: EventValidation<T>) => any;
|
30 | }) => Promise<boolean>;
|
31 | }
|
32 |
|
33 | export default function useSValidation<T = any>(
|
34 | props: UseSValidationProps<T>
|
35 | ): UseSValidation<T>;
|