@splitty-test/validation 0.2.9 → 0.2.11
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/README.md +7 -5
- package/dist/FieldValidation.vue.d.ts +3 -1
- package/dist/FormValidator.d.ts +1 -2
- package/dist/index.mjs +403 -383
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,12 +49,12 @@ In the template:
|
|
|
49
49
|
<template>
|
|
50
50
|
<div class='login-form'>
|
|
51
51
|
<div class='email-field'>
|
|
52
|
-
<FieldValidation name="email"
|
|
52
|
+
<FieldValidation name="email" :value="email" :validator="login_form_validator" :rules="[rules.required, rules.email]">
|
|
53
53
|
<input name="email" v-model="email">
|
|
54
54
|
</FieldValidation>
|
|
55
55
|
</div>
|
|
56
56
|
<div class='password-field'>
|
|
57
|
-
<FieldValidation name="password"
|
|
57
|
+
<FieldValidation name="password" :value="password" :validator="login_form_validator" :rules="[rules.required]">
|
|
58
58
|
<input name="password" v-model="password">
|
|
59
59
|
</FieldValidation>
|
|
60
60
|
</div>
|
|
@@ -68,9 +68,11 @@ In the template:
|
|
|
68
68
|
### FieldValidation Component Properties
|
|
69
69
|
|
|
70
70
|
- **name (String) - Required:** A unique name for the field that is used intenally to reference the field being validated.
|
|
71
|
-
-
|
|
71
|
+
- **:value (any) - Required:** The value that is being validated.
|
|
72
|
+
- **group (String):** A group name for validating subsets of fields.
|
|
72
73
|
- **validator (FormValidator) - Required:** The instance of the FormValidator that the field is attached to.
|
|
73
74
|
- **rules (Rule[]): - Conditionally Required** Rules are a list of functions used to validated the value in the v-model. It is only required on the FieldValidation component if they weren't defined when creating the FormValidator.
|
|
75
|
+
- **el (String):** The HTML element in the slot that you want validation triggers applied to. The string should be a selector. For instance, if you want to use a PrimeVue `Select` component inside the validator, you should set `el=".p-select-label"`
|
|
74
76
|
|
|
75
77
|
### Making Custom Rules
|
|
76
78
|
|
|
@@ -108,6 +110,6 @@ export {
|
|
|
108
110
|
Then in the template:
|
|
109
111
|
|
|
110
112
|
```html
|
|
111
|
-
<FieldValidation name="pity"
|
|
112
|
-
<FieldValidation name="age"
|
|
113
|
+
<FieldValidation name="pity" :value="who_do_i_pity" :validator="myValidator" :rules="[myCustomRule]">...</FieldVaidation>
|
|
114
|
+
<FieldValidation name="age" :value="age" :validator="myValidator" :rules="[myCustomRuleWithArguments(18, 50)]">...</FieldVaidation>
|
|
113
115
|
```
|
|
@@ -35,7 +35,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
35
35
|
}, {
|
|
36
36
|
field(): import('./FieldValidator').FieldValidator;
|
|
37
37
|
error(): string | null | undefined;
|
|
38
|
-
}, {
|
|
38
|
+
}, {
|
|
39
|
+
validate(event: FocusEvent): void;
|
|
40
|
+
}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
39
41
|
el: {
|
|
40
42
|
type: StringConstructor;
|
|
41
43
|
default: string;
|
package/dist/FormValidator.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { FieldValidator, FieldValidatorConfig, FieldValidatorOptions, Validation
|
|
|
3
3
|
import { FieldValidatorGroup } from './FieldValidatorGroup';
|
|
4
4
|
export interface FormValidator {
|
|
5
5
|
dirty: Ref<boolean, boolean>;
|
|
6
|
-
errors: Reactive<string[]>;
|
|
7
6
|
fields: Reactive<Record<string, FieldValidator>>;
|
|
8
7
|
groups: Reactive<Record<string, FieldValidatorGroup>>;
|
|
9
8
|
touched: Ref<boolean, boolean>;
|
|
@@ -18,7 +17,6 @@ export interface FormValidator {
|
|
|
18
17
|
export type FormValidatorConfig = Record<string, FieldValidatorConfig>;
|
|
19
18
|
export declare function useFormValidator(config?: FormValidatorConfig): {
|
|
20
19
|
dirty: Ref<boolean, boolean>;
|
|
21
|
-
errors: Reactive<string[]>;
|
|
22
20
|
fields: Record<string, FieldValidator>;
|
|
23
21
|
groups: Record<string, FieldValidatorGroup>;
|
|
24
22
|
touched: Ref<boolean, boolean>;
|
|
@@ -27,6 +25,7 @@ export declare function useFormValidator(config?: FormValidatorConfig): {
|
|
|
27
25
|
removeField: (field_name: string) => void;
|
|
28
26
|
validate: (group_name?: string) => Promise<boolean>;
|
|
29
27
|
isValid: (group_name?: string) => boolean;
|
|
28
|
+
getErrors: () => Record<string, string[]>;
|
|
30
29
|
setTouched: () => void;
|
|
31
30
|
reset: (group_name?: string) => void;
|
|
32
31
|
};
|