vee-validate 4.2.3 → 4.3.0
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/CHANGELOG.md +24 -0
- package/dist/vee-validate.d.ts +52 -42
- package/dist/vee-validate.esm.js +133 -106
- package/dist/vee-validate.js +133 -106
- package/dist/vee-validate.min.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.3.0](https://github.com/logaretm/vee-validate/compare/v4.2.4...v4.3.0) (2021-04-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* added support for reactive schemas ([#3238](https://github.com/logaretm/vee-validate/issues/3238)) ([295d656](https://github.com/logaretm/vee-validate/commit/295d6567035bc3c452ad0f13fce13ff362b08005))
|
|
12
|
+
* added support for setting multiple field errors closes [#3117](https://github.com/logaretm/vee-validate/issues/3117) ([db0a6a0](https://github.com/logaretm/vee-validate/commit/db0a6a02cdc0fdab02a18e4756005c46dc06b1f8))
|
|
13
|
+
* support v-model.number ([#3252](https://github.com/logaretm/vee-validate/issues/3252)) ([8f491da](https://github.com/logaretm/vee-validate/commit/8f491da0b0998d0f7383a6a444d6aa498e3d96f4))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [4.2.4](https://github.com/logaretm/vee-validate/compare/v4.2.3...v4.2.4) (2021-03-26)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* validation triggered on value change ([10549b7](https://github.com/logaretm/vee-validate/commit/10549b77dc350cee4f198cb14e3fd12f61e12b80))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [4.2.3](https://github.com/logaretm/vee-validate/compare/v4.2.2...v4.2.3) (2021-03-22)
|
|
7
31
|
|
|
8
32
|
|
package/dist/vee-validate.d.ts
CHANGED
|
@@ -20,13 +20,13 @@ interface ValidationResult {
|
|
|
20
20
|
valid: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare type YupValidator = AnySchema | AnyObjectSchema;
|
|
23
|
-
declare type
|
|
23
|
+
declare type MaybeRef<T> = Ref<T> | ComputedRef<T> | T;
|
|
24
24
|
interface FieldMeta<TValue> {
|
|
25
25
|
touched: boolean;
|
|
26
26
|
dirty: boolean;
|
|
27
27
|
valid: boolean;
|
|
28
|
+
validated: boolean;
|
|
28
29
|
pending: boolean;
|
|
29
|
-
hadValueUserInteraction: boolean;
|
|
30
30
|
initialValue?: TValue;
|
|
31
31
|
}
|
|
32
32
|
interface FieldState<TValue = unknown> {
|
|
@@ -38,14 +38,14 @@ declare type WritableRef<TValue> = Ref<TValue> | WritableComputedRef<TValue>;
|
|
|
38
38
|
interface PrivateFieldComposite<TValue = unknown> {
|
|
39
39
|
fid: number;
|
|
40
40
|
idx: number;
|
|
41
|
-
name:
|
|
41
|
+
name: MaybeRef<string>;
|
|
42
42
|
value: WritableRef<TValue>;
|
|
43
43
|
meta: FieldMeta<TValue>;
|
|
44
44
|
errors: Ref<string[]>;
|
|
45
45
|
errorMessage: ComputedRef<string | undefined>;
|
|
46
46
|
type?: string;
|
|
47
|
-
valueProp?:
|
|
48
|
-
uncheckedValue?:
|
|
47
|
+
valueProp?: MaybeRef<TValue>;
|
|
48
|
+
uncheckedValue?: MaybeRef<TValue>;
|
|
49
49
|
checked?: ComputedRef<boolean>;
|
|
50
50
|
resetField(state?: FieldState<TValue>): void;
|
|
51
51
|
handleReset(state?: FieldState<TValue>): void;
|
|
@@ -55,11 +55,9 @@ interface PrivateFieldComposite<TValue = unknown> {
|
|
|
55
55
|
handleInput(e?: Event | unknown): void;
|
|
56
56
|
setValidationState(state: ValidationResult): void;
|
|
57
57
|
setTouched(isTouched: boolean): void;
|
|
58
|
+
setErrors(message: string | string[]): void;
|
|
58
59
|
}
|
|
59
60
|
declare type FieldComposable<TValue = unknown> = Omit<PrivateFieldComposite<TValue>, 'idx' | 'fid'>;
|
|
60
|
-
declare type SubmitEvent = Event & {
|
|
61
|
-
target: HTMLFormElement;
|
|
62
|
-
};
|
|
63
61
|
declare type GenericValidateFunction = (value: unknown, ctx: FieldContext) => boolean | string | Promise<boolean | string>;
|
|
64
62
|
interface FormState<TValues> {
|
|
65
63
|
values: TValues;
|
|
@@ -74,7 +72,7 @@ interface SetFieldValueOptions {
|
|
|
74
72
|
}
|
|
75
73
|
interface FormActions<TValues extends Record<string, unknown>> {
|
|
76
74
|
setFieldValue<T extends keyof TValues>(field: T, value: TValues[T], opts?: Partial<SetFieldValueOptions>): void;
|
|
77
|
-
setFieldError: (field: keyof TValues, message: string | undefined) => void;
|
|
75
|
+
setFieldError: (field: keyof TValues, message: string | string[] | undefined) => void;
|
|
78
76
|
setErrors: (fields: FormErrors<TValues>) => void;
|
|
79
77
|
setValues<T extends keyof TValues>(fields: Partial<Record<T, TValues[T]>>): void;
|
|
80
78
|
setFieldTouched: (field: keyof TValues, isTouched: boolean) => void;
|
|
@@ -86,21 +84,27 @@ interface FormValidationResult<TValues> {
|
|
|
86
84
|
valid: boolean;
|
|
87
85
|
}
|
|
88
86
|
interface SubmissionContext<TValues extends Record<string, unknown> = Record<string, unknown>> extends FormActions<TValues> {
|
|
89
|
-
evt
|
|
87
|
+
evt?: Event;
|
|
90
88
|
}
|
|
91
89
|
declare type SubmissionHandler<TValues extends Record<string, unknown> = Record<string, unknown>> = (values: TValues, ctx: SubmissionContext<TValues>) => unknown;
|
|
90
|
+
/**
|
|
91
|
+
* validated-only: only mutate the previously validated fields
|
|
92
|
+
* silent: do not mutate any field
|
|
93
|
+
* force: validate all fields and mutate their state
|
|
94
|
+
*/
|
|
95
|
+
declare type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
|
|
92
96
|
interface FormContext<TValues extends Record<string, any> = Record<string, any>> extends FormActions<TValues> {
|
|
93
97
|
register(field: PrivateFieldComposite): void;
|
|
94
98
|
unregister(field: PrivateFieldComposite): void;
|
|
95
99
|
values: TValues;
|
|
96
100
|
fieldsById: ComputedRef<Record<keyof TValues, PrivateFieldComposite | PrivateFieldComposite[]>>;
|
|
97
101
|
submitCount: Ref<number>;
|
|
98
|
-
schema?: Record<keyof TValues, GenericValidateFunction | string | Record<string, any>> | SchemaOf<TValues
|
|
99
|
-
validateSchema?: (
|
|
102
|
+
schema?: MaybeRef<Record<keyof TValues, GenericValidateFunction | string | Record<string, any>> | SchemaOf<TValues>>;
|
|
103
|
+
validateSchema?: (mode: SchemaValidationMode) => Promise<Record<keyof TValues, ValidationResult>>;
|
|
100
104
|
validate(): Promise<FormValidationResult<TValues>>;
|
|
101
105
|
validateField(field: keyof TValues): Promise<ValidationResult>;
|
|
102
106
|
errorBag: Ref<FormErrorBag<TValues>>;
|
|
103
|
-
setFieldErrorBag(field: string, messages: string[]): void;
|
|
107
|
+
setFieldErrorBag(field: string, messages: string | string[]): void;
|
|
104
108
|
stageInitialValue(path: string, value: unknown): void;
|
|
105
109
|
meta: ComputedRef<{
|
|
106
110
|
dirty: boolean;
|
|
@@ -110,7 +114,7 @@ interface FormContext<TValues extends Record<string, any> = Record<string, any>>
|
|
|
110
114
|
initialValues: TValues;
|
|
111
115
|
}>;
|
|
112
116
|
isSubmitting: Ref<boolean>;
|
|
113
|
-
handleSubmit(cb: SubmissionHandler<TValues>): (e?:
|
|
117
|
+
handleSubmit(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<void>;
|
|
114
118
|
}
|
|
115
119
|
interface PublicFormContext<TValues extends Record<string, any> = Record<string, any>> extends Omit<FormContext<TValues>, 'register' | 'unregister' | 'fieldsById' | 'schema' | 'validateSchema' | 'errorBag' | 'setFieldErrorBag' | 'stageInitialValue'> {
|
|
116
120
|
errors: ComputedRef<FormErrors<TValues>>;
|
|
@@ -193,13 +197,17 @@ declare const Field: vue.DefineComponent<{
|
|
|
193
197
|
modelValue: {
|
|
194
198
|
type: any;
|
|
195
199
|
};
|
|
200
|
+
modelModifiers: {
|
|
201
|
+
type: any;
|
|
202
|
+
default: () => {};
|
|
203
|
+
};
|
|
196
204
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
197
205
|
[key: string]: any;
|
|
198
206
|
}> | vue.Slot | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
199
207
|
[key: string]: any;
|
|
200
208
|
}>[], unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{
|
|
201
|
-
label:
|
|
202
|
-
name:
|
|
209
|
+
label: unknown;
|
|
210
|
+
name: unknown;
|
|
203
211
|
uncheckedValue: any;
|
|
204
212
|
bails: boolean;
|
|
205
213
|
validateOnInput: boolean;
|
|
@@ -207,11 +215,12 @@ declare const Field: vue.DefineComponent<{
|
|
|
207
215
|
validateOnBlur: boolean;
|
|
208
216
|
validateOnModelUpdate: boolean;
|
|
209
217
|
validateOnMount: boolean;
|
|
210
|
-
as:
|
|
211
|
-
rules:
|
|
218
|
+
as: unknown;
|
|
219
|
+
rules: unknown;
|
|
212
220
|
modelValue: any;
|
|
221
|
+
modelModifiers: any;
|
|
213
222
|
} & {}>, {
|
|
214
|
-
label:
|
|
223
|
+
label: unknown;
|
|
215
224
|
uncheckedValue: any;
|
|
216
225
|
bails: boolean;
|
|
217
226
|
validateOnInput: boolean;
|
|
@@ -219,9 +228,10 @@ declare const Field: vue.DefineComponent<{
|
|
|
219
228
|
validateOnBlur: boolean;
|
|
220
229
|
validateOnModelUpdate: boolean;
|
|
221
230
|
validateOnMount: boolean;
|
|
222
|
-
as:
|
|
223
|
-
rules:
|
|
231
|
+
as: unknown;
|
|
232
|
+
rules: unknown;
|
|
224
233
|
modelValue: any;
|
|
234
|
+
modelModifiers: any;
|
|
225
235
|
}>;
|
|
226
236
|
|
|
227
237
|
declare const Form: vue.DefineComponent<{
|
|
@@ -258,17 +268,17 @@ declare const Form: vue.DefineComponent<{
|
|
|
258
268
|
}> | vue.Slot | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
259
269
|
[key: string]: any;
|
|
260
270
|
}>[], unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{
|
|
261
|
-
onSubmit:
|
|
271
|
+
onSubmit: unknown;
|
|
262
272
|
validateOnMount: boolean;
|
|
263
|
-
as:
|
|
273
|
+
as: unknown;
|
|
264
274
|
initialValues: Record<string, any>;
|
|
265
275
|
validationSchema: Record<string, any>;
|
|
266
276
|
initialErrors: Record<string, any>;
|
|
267
277
|
initialTouched: Record<string, any>;
|
|
268
278
|
} & {}>, {
|
|
269
|
-
onSubmit:
|
|
279
|
+
onSubmit: unknown;
|
|
270
280
|
validateOnMount: boolean;
|
|
271
|
-
as:
|
|
281
|
+
as: unknown;
|
|
272
282
|
initialValues: Record<string, any>;
|
|
273
283
|
validationSchema: Record<string, any>;
|
|
274
284
|
initialErrors: Record<string, any>;
|
|
@@ -289,31 +299,31 @@ declare const ErrorMessage: vue.DefineComponent<{
|
|
|
289
299
|
}> | vue.Slot | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
290
300
|
[key: string]: any;
|
|
291
301
|
}>[], unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{
|
|
292
|
-
name:
|
|
293
|
-
as:
|
|
302
|
+
name: unknown;
|
|
303
|
+
as: unknown;
|
|
294
304
|
} & {}>, {
|
|
295
|
-
as:
|
|
305
|
+
as: unknown;
|
|
296
306
|
}>;
|
|
297
307
|
|
|
298
308
|
interface FieldOptions<TValue = unknown> {
|
|
299
|
-
initialValue?:
|
|
309
|
+
initialValue?: MaybeRef<TValue>;
|
|
300
310
|
validateOnValueUpdate: boolean;
|
|
301
311
|
validateOnMount?: boolean;
|
|
302
312
|
bails?: boolean;
|
|
303
313
|
type?: string;
|
|
304
|
-
valueProp?:
|
|
305
|
-
uncheckedValue?:
|
|
306
|
-
label?:
|
|
314
|
+
valueProp?: MaybeRef<TValue>;
|
|
315
|
+
uncheckedValue?: MaybeRef<TValue>;
|
|
316
|
+
label?: MaybeRef<string>;
|
|
307
317
|
}
|
|
308
318
|
declare type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction | YupValidator | BaseSchema<TValue> | undefined;
|
|
309
319
|
/**
|
|
310
320
|
* Creates a field composite.
|
|
311
321
|
*/
|
|
312
|
-
declare function useField<TValue = unknown>(name:
|
|
322
|
+
declare function useField<TValue = unknown>(name: MaybeRef<string>, rules?: MaybeRef<RuleExpression<TValue>>, opts?: Partial<FieldOptions<TValue>>): FieldComposable<TValue>;
|
|
313
323
|
|
|
314
324
|
interface FormOptions<TValues extends Record<string, any>> {
|
|
315
|
-
validationSchema?: Record<keyof TValues, GenericValidateFunction | string | Record<string, any>> | SchemaOf<TValues
|
|
316
|
-
initialValues?:
|
|
325
|
+
validationSchema?: MaybeRef<Record<keyof TValues, GenericValidateFunction | string | Record<string, any>> | SchemaOf<TValues>>;
|
|
326
|
+
initialValues?: MaybeRef<TValues>;
|
|
317
327
|
initialErrors?: Record<keyof TValues, string | undefined>;
|
|
318
328
|
initialTouched?: Record<keyof TValues, boolean>;
|
|
319
329
|
validateOnMount?: boolean;
|
|
@@ -325,17 +335,17 @@ declare function useResetForm<TValues extends Record<string, unknown> = Record<s
|
|
|
325
335
|
/**
|
|
326
336
|
* If a field is dirty or not
|
|
327
337
|
*/
|
|
328
|
-
declare function useIsFieldDirty(path?:
|
|
338
|
+
declare function useIsFieldDirty(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
|
|
329
339
|
|
|
330
340
|
/**
|
|
331
341
|
* If a field is touched or not
|
|
332
342
|
*/
|
|
333
|
-
declare function useIsFieldTouched(path?:
|
|
343
|
+
declare function useIsFieldTouched(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
|
|
334
344
|
|
|
335
345
|
/**
|
|
336
346
|
* If a field is validated and is valid
|
|
337
347
|
*/
|
|
338
|
-
declare function useIsFieldValid(path?:
|
|
348
|
+
declare function useIsFieldValid(path?: MaybeRef<string>): vue.ComputedRef<boolean>;
|
|
339
349
|
|
|
340
350
|
/**
|
|
341
351
|
* If the form is submitting or not
|
|
@@ -345,7 +355,7 @@ declare function useIsSubmitting(): vue.ComputedRef<boolean>;
|
|
|
345
355
|
/**
|
|
346
356
|
* Validates a single field
|
|
347
357
|
*/
|
|
348
|
-
declare function useValidateField(path?:
|
|
358
|
+
declare function useValidateField(path?: MaybeRef<string>): () => Promise<ValidationResult>;
|
|
349
359
|
|
|
350
360
|
/**
|
|
351
361
|
* If the form is dirty or not
|
|
@@ -375,7 +385,7 @@ declare function useSubmitCount(): vue.ComputedRef<number>;
|
|
|
375
385
|
/**
|
|
376
386
|
* Gives access to a field's current value
|
|
377
387
|
*/
|
|
378
|
-
declare function useFieldValue<TValue = unknown>(path?:
|
|
388
|
+
declare function useFieldValue<TValue = unknown>(path?: MaybeRef<string>): vue.ComputedRef<TValue>;
|
|
379
389
|
|
|
380
390
|
/**
|
|
381
391
|
* Gives access to a form's values
|
|
@@ -390,8 +400,8 @@ declare function useFormErrors<TValues extends Record<string, unknown> = Record<
|
|
|
390
400
|
/**
|
|
391
401
|
* Gives access to a single field error
|
|
392
402
|
*/
|
|
393
|
-
declare function useFieldError(path?:
|
|
403
|
+
declare function useFieldError(path?: MaybeRef<string>): vue.ComputedRef<string>;
|
|
394
404
|
|
|
395
|
-
declare function useSubmitForm<TValues extends Record<string, unknown> = Record<string, unknown>>(cb: SubmissionHandler<TValues>): (e?:
|
|
405
|
+
declare function useSubmitForm<TValues extends Record<string, unknown> = Record<string, unknown>>(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<void>;
|
|
396
406
|
|
|
397
407
|
export { ErrorMessage, Field, Form, FormActions, FormContext, FormState, FormValidationResult, PublicFormContext, SubmissionContext, SubmissionHandler, ValidationResult, configure, defineRule, useField, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate };
|