@splitty-test/validation 0.1.0 → 0.1.1
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/FieldValidation.vue.d.ts +54 -0
- package/dist/FieldValidatorClass.d.ts +22 -0
- package/dist/ValidatorClass.d.ts +24 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +1994 -0
- package/dist/index.umd.js +1 -0
- package/dist/rules/index.d.ts +2 -0
- package/dist/rules/match.d.ts +1 -0
- package/package.json +15 -15
- package/{lib → src}/FieldValidation.vue +36 -14
- package/{lib → src}/FieldValidatorClass.ts +14 -36
- package/{lib → src}/ValidatorClass.ts +26 -26
- package/src/rules/index.ts +3 -0
- package/src/rules/match.ts +8 -0
- package/vite.config.ts +9 -8
- package/lib/rules/index.ts +0 -0
- package/lib/rules/match.ts +0 -0
- /package/{lib → src}/index.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { Validator } from './ValidatorClass';
|
|
3
|
+
import { ValidationRule } from './FieldValidatorClass';
|
|
4
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
name: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
hideError: BooleanConstructor;
|
|
10
|
+
modelValue: {
|
|
11
|
+
type: null;
|
|
12
|
+
};
|
|
13
|
+
modelModifiers: {
|
|
14
|
+
default: () => {};
|
|
15
|
+
};
|
|
16
|
+
rules: {
|
|
17
|
+
type: PropType<ValidationRule[]>;
|
|
18
|
+
default(): never[];
|
|
19
|
+
};
|
|
20
|
+
validator: {
|
|
21
|
+
type: typeof Validator;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
}>, {}, {
|
|
25
|
+
form_fields: HTMLElement[];
|
|
26
|
+
}, {
|
|
27
|
+
field(): import('./FieldValidatorClass').FieldValidator;
|
|
28
|
+
error(): string | null | undefined;
|
|
29
|
+
}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
30
|
+
name: {
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
hideError: BooleanConstructor;
|
|
35
|
+
modelValue: {
|
|
36
|
+
type: null;
|
|
37
|
+
};
|
|
38
|
+
modelModifiers: {
|
|
39
|
+
default: () => {};
|
|
40
|
+
};
|
|
41
|
+
rules: {
|
|
42
|
+
type: PropType<ValidationRule[]>;
|
|
43
|
+
default(): never[];
|
|
44
|
+
};
|
|
45
|
+
validator: {
|
|
46
|
+
type: typeof Validator;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {
|
|
50
|
+
hideError: boolean;
|
|
51
|
+
modelModifiers: {};
|
|
52
|
+
rules: ValidationRule[];
|
|
53
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
54
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Validator } from './ValidatorClass';
|
|
2
|
+
export interface FieldValidatorConfig {
|
|
3
|
+
value: any;
|
|
4
|
+
rules: ValidationRule[];
|
|
5
|
+
group?: string;
|
|
6
|
+
}
|
|
7
|
+
export type ValidationRule = (value: any, ...args: any) => Promise<string | null> | (string | null);
|
|
8
|
+
export declare class FieldValidator {
|
|
9
|
+
controls: HTMLElement[];
|
|
10
|
+
dirty: boolean;
|
|
11
|
+
errors: string[];
|
|
12
|
+
group?: string;
|
|
13
|
+
rules: ValidationRule[];
|
|
14
|
+
touched: boolean;
|
|
15
|
+
validated: boolean;
|
|
16
|
+
validator: Validator;
|
|
17
|
+
value: any;
|
|
18
|
+
constructor(config: FieldValidatorConfig, validator: Validator);
|
|
19
|
+
get isValid(): boolean;
|
|
20
|
+
reset(): void;
|
|
21
|
+
validate(): Promise<boolean>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FieldValidator, FieldValidatorConfig } from './FieldValidatorClass';
|
|
2
|
+
export interface ValidatorConfig {
|
|
3
|
+
fields?: Record<string, FieldValidatorConfig>;
|
|
4
|
+
}
|
|
5
|
+
export interface ValidationGroup {
|
|
6
|
+
dirty: boolean;
|
|
7
|
+
fields: Record<string, FieldValidator>;
|
|
8
|
+
touched: boolean;
|
|
9
|
+
validated: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class Validator {
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
errors: string[];
|
|
14
|
+
fields: Record<string, FieldValidator>;
|
|
15
|
+
groups: Record<string, ValidationGroup>;
|
|
16
|
+
touched: boolean;
|
|
17
|
+
validated: boolean;
|
|
18
|
+
constructor(config?: ValidatorConfig);
|
|
19
|
+
isValid(group_name?: string): boolean;
|
|
20
|
+
reset(group_name?: string): void;
|
|
21
|
+
addField(field_name: string, field_config: FieldValidatorConfig): void;
|
|
22
|
+
removeField(field_name: string): void;
|
|
23
|
+
validate(group_name?: string): Promise<void>;
|
|
24
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Validator } from './ValidatorClass';
|
|
2
|
+
import { FieldValidator } from './FieldValidatorClass';
|
|
3
|
+
import { default as FieldValidation } from './FieldValidation.vue';
|
|
4
|
+
import * as rules from './rules';
|
|
5
|
+
export { Validator, FieldValidator, FieldValidation, rules };
|