vee-validate 4.7.3 → 4.8.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.
@@ -3,6 +3,8 @@ import { Ref, ComputedRef, PropType, VNode, UnwrapRef, InjectionKey } from 'vue'
3
3
 
4
4
  interface FieldValidationMetaInfo {
5
5
  field: string;
6
+ name: string;
7
+ label?: string;
6
8
  value: unknown;
7
9
  form: Record<string, unknown>;
8
10
  rule?: {
@@ -10,19 +12,32 @@ interface FieldValidationMetaInfo {
10
12
  params?: Record<string, unknown> | unknown[];
11
13
  };
12
14
  }
13
- declare type ValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
14
- declare type SimpleValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams) => boolean | string | Promise<boolean | string>;
15
- declare type ValidationMessageGenerator = (ctx: FieldValidationMetaInfo) => string;
15
+ type ValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
16
+ type SimpleValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams) => boolean | string | Promise<boolean | string>;
17
+ type ValidationMessageGenerator = (ctx: FieldValidationMetaInfo) => string;
16
18
 
17
- declare type GenericFormValues = Record<string, unknown>;
19
+ type GenericFormValues = Record<string, any>;
18
20
  interface ValidationResult {
19
21
  errors: string[];
20
22
  valid: boolean;
21
23
  }
22
- declare type YupValidator<TValue = any> = {
23
- validate(value: TValue, options: Record<string, any>): Promise<TValue>;
24
+ interface TypedSchemaError {
25
+ path?: string;
26
+ errors: string[];
27
+ }
28
+ interface TypedSchema<TInput = any, TOutput = TInput> {
29
+ __type: 'VVTypedSchema';
30
+ parse(values: TInput): Promise<{
31
+ value?: TOutput;
32
+ errors: TypedSchemaError[];
33
+ }>;
34
+ cast?(values: Partial<TInput>): TInput;
35
+ }
36
+ type YupSchema<TValues = any> = {
37
+ __isYupSchema__: boolean;
38
+ validate(value: any, options: Record<string, any>): Promise<any>;
24
39
  };
25
- declare type MaybeRef<T> = Ref<T> | T;
40
+ type MaybeRef<T> = Ref<T> | T;
26
41
  interface FieldMeta<TValue> {
27
42
  touched: boolean;
28
43
  dirty: boolean;
@@ -49,7 +64,7 @@ interface FieldState<TValue = unknown> {
49
64
  * silent: do not mutate any field
50
65
  * force: validate all fields and mutate their state
51
66
  */
52
- declare type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
67
+ type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
53
68
  interface ValidationOptions$1 {
54
69
  mode: SchemaValidationMode;
55
70
  }
@@ -98,65 +113,67 @@ interface PrivateFieldContext<TValue = unknown> {
98
113
  setErrors(message: string | string[]): void;
99
114
  setValue(value: TValue): void;
100
115
  }
101
- declare type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
102
- declare type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
116
+ type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
117
+ type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
103
118
  interface FormState<TValues> {
104
119
  values: TValues;
105
120
  errors: Partial<Record<keyof TValues, string | undefined>>;
106
121
  touched: Partial<Record<keyof TValues, boolean>>;
107
122
  submitCount: number;
108
123
  }
109
- declare type FormErrors<TValues extends GenericFormValues> = Partial<Record<keyof TValues, string | undefined>>;
110
- declare type FormErrorBag<TValues extends GenericFormValues> = Partial<Record<keyof TValues, string[]>>;
124
+ type FormErrors<TValues extends GenericFormValues> = Partial<Record<keyof TValues, string | undefined>>;
125
+ type FormErrorBag<TValues extends GenericFormValues> = Partial<Record<keyof TValues, string[]>>;
111
126
  interface SetFieldValueOptions {
112
127
  force: boolean;
113
128
  }
114
- interface FormActions<TValues extends GenericFormValues> {
129
+ interface FormActions<TValues extends GenericFormValues, TOutput extends TValues = TValues> {
115
130
  setFieldValue<T extends keyof TValues>(field: T, value: TValues[T], opts?: Partial<SetFieldValueOptions>): void;
116
- setFieldError: (field: keyof TValues, message: string | string[] | undefined) => void;
117
- setErrors: (fields: FormErrors<TValues>) => void;
131
+ setFieldError(field: keyof TValues, message: string | string[] | undefined): void;
132
+ setErrors(fields: FormErrors<TValues>): void;
118
133
  setValues<T extends keyof TValues>(fields: Partial<Record<T, TValues[T]>>): void;
119
- setFieldTouched: (field: keyof TValues, isTouched: boolean) => void;
120
- setTouched: (fields: Partial<Record<keyof TValues, boolean>>) => void;
121
- resetForm: (state?: Partial<FormState<TValues>>) => void;
134
+ setFieldTouched(field: keyof TValues, isTouched: boolean): void;
135
+ setTouched(fields: Partial<Record<keyof TValues, boolean>>): void;
136
+ resetForm(state?: Partial<FormState<TValues>>): void;
137
+ resetField(field: keyof TValues, state?: Partial<FieldState>): void;
122
138
  }
123
- interface FormValidationResult<TValues> {
139
+ interface FormValidationResult<TValues, TOutput = TValues> {
124
140
  valid: boolean;
125
141
  results: Partial<Record<keyof TValues, ValidationResult>>;
126
142
  errors: Partial<Record<keyof TValues, string>>;
143
+ values?: TOutput;
127
144
  }
128
145
  interface SubmissionContext<TValues extends GenericFormValues = GenericFormValues> extends FormActions<TValues> {
129
146
  evt?: Event;
130
147
  controlledValues: Partial<TValues>;
131
148
  }
132
- declare type SubmissionHandler<TValues extends GenericFormValues = GenericFormValues, TReturn = unknown> = (values: TValues, ctx: SubmissionContext<TValues>) => TReturn;
149
+ type SubmissionHandler<TValues extends GenericFormValues = GenericFormValues, TOutput extends TValues = TValues, TReturn = unknown> = (values: TOutput, ctx: SubmissionContext<TValues>) => TReturn;
133
150
  interface InvalidSubmissionContext<TValues extends GenericFormValues = GenericFormValues> {
134
151
  values: TValues;
135
152
  evt?: Event;
136
153
  errors: Partial<Record<keyof TValues, string>>;
137
154
  results: Partial<Record<keyof TValues, ValidationResult>>;
138
155
  }
139
- declare type InvalidSubmissionHandler<TValues extends GenericFormValues = GenericFormValues> = (ctx: InvalidSubmissionContext<TValues>) => void;
140
- declare type RawFormSchema<TValues> = Record<keyof TValues, string | GenericValidateFunction | Record<string, any>>;
141
- declare type FieldPathLookup<TValues extends Record<string, any> = Record<string, any>> = Partial<Record<keyof TValues, PrivateFieldContext | PrivateFieldContext[]>>;
142
- declare type MapValues<T, TValues extends Record<string, any>> = {
156
+ type InvalidSubmissionHandler<TValues extends GenericFormValues = GenericFormValues> = (ctx: InvalidSubmissionContext<TValues>) => void;
157
+ type RawFormSchema<TValues> = Record<keyof TValues, string | GenericValidateFunction | Record<string, any>>;
158
+ type FieldPathLookup<TValues extends Record<string, any> = Record<string, any>> = Partial<Record<keyof TValues, PrivateFieldContext | PrivateFieldContext[]>>;
159
+ type MapValues<T, TValues extends Record<string, any>> = {
143
160
  [K in keyof T]: T[K] extends MaybeRef<infer TKey> ? TKey extends keyof TValues ? Ref<TValues[TKey]> : Ref<unknown> : Ref<unknown>;
144
161
  };
145
- declare type HandleSubmitFactory<TValues extends GenericFormValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
146
- interface PrivateFormContext<TValues extends Record<string, any> = Record<string, any>> extends FormActions<TValues> {
162
+ type HandleSubmitFactory<TValues extends GenericFormValues, TOutput extends TValues = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
163
+ interface PrivateFormContext<TValues extends GenericFormValues = GenericFormValues, TOutput extends TValues = TValues> extends FormActions<TValues> {
147
164
  formId: number;
148
165
  values: TValues;
149
166
  controlledValues: Ref<TValues>;
150
167
  fieldsByPath: Ref<FieldPathLookup>;
151
168
  fieldArrays: PrivateFieldArrayContext[];
152
169
  submitCount: Ref<number>;
153
- schema?: MaybeRef<RawFormSchema<TValues> | YupValidator<TValues> | undefined>;
170
+ schema?: MaybeRef<RawFormSchema<TValues> | TypedSchema<TValues, TOutput> | YupSchema<TValues> | undefined>;
154
171
  errorBag: Ref<FormErrorBag<TValues>>;
155
172
  errors: ComputedRef<FormErrors<TValues>>;
156
173
  meta: ComputedRef<FormMeta<TValues>>;
157
174
  isSubmitting: Ref<boolean>;
158
175
  keepValuesOnUnmount: MaybeRef<boolean>;
159
- validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues>>;
176
+ validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
160
177
  validate(opts?: Partial<ValidationOptions$1>): Promise<FormValidationResult<TValues>>;
161
178
  validateField(field: keyof TValues): Promise<ValidationResult>;
162
179
  setFieldErrorBag(field: string, messages: string | string[]): void;
@@ -164,27 +181,35 @@ interface PrivateFormContext<TValues extends Record<string, any> = Record<string
164
181
  unsetInitialValue(path: string): void;
165
182
  register(field: PrivateFieldContext): void;
166
183
  unregister(field: PrivateFieldContext): void;
167
- handleSubmit: HandleSubmitFactory<TValues> & {
168
- withControlled: HandleSubmitFactory<TValues>;
184
+ handleSubmit: HandleSubmitFactory<TValues, TOutput> & {
185
+ withControlled: HandleSubmitFactory<TValues, TOutput>;
169
186
  };
170
187
  setFieldInitialValue(path: string, value: unknown): void;
171
188
  useFieldModel<TPath extends keyof TValues>(path: MaybeRef<TPath>): Ref<TValues[TPath]>;
172
189
  useFieldModel<TPath extends keyof TValues>(paths: [...MaybeRef<TPath>[]]): MapValues<typeof paths, TValues>;
173
190
  }
174
- interface FormContext<TValues extends Record<string, any> = Record<string, any>> extends Omit<PrivateFormContext<TValues>, 'formId' | 'register' | 'unregister' | 'fieldsByPath' | 'schema' | 'validateSchema' | 'errorBag' | 'setFieldErrorBag' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'keepValuesOnUnmount'> {
191
+ interface FormContext<TValues extends Record<string, any> = Record<string, any>, TOutput extends TValues = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'register' | 'unregister' | 'fieldsByPath' | 'schema' | 'validateSchema' | 'setFieldErrorBag' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'keepValuesOnUnmount'> {
175
192
  handleReset: () => void;
176
193
  submitForm: (e?: unknown) => Promise<void>;
177
194
  }
178
195
 
179
196
  interface ValidationOptions {
180
197
  name?: string;
198
+ label?: string;
181
199
  values?: Record<string, unknown>;
182
200
  bails?: boolean;
183
201
  }
184
202
  /**
185
203
  * Validates a value against the rules.
186
204
  */
187
- declare function validate<TValue = unknown>(value: TValue, rules: string | Record<string, unknown | unknown[]> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | YupValidator, options?: ValidationOptions): Promise<ValidationResult>;
205
+ declare function validate<TValue = unknown>(value: TValue, rules: string | Record<string, unknown | unknown[]> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | TypedSchema<TValue>, options?: ValidationOptions): Promise<ValidationResult>;
206
+ declare function validateObjectSchema<TValues, TOutput>(schema: RawFormSchema<TValues>, values: TValues, opts?: Partial<{
207
+ names: Record<string, {
208
+ name: string;
209
+ label: string;
210
+ }>;
211
+ bailsMap: Record<string, boolean>;
212
+ }>): Promise<FormValidationResult<TValues, TOutput>>;
188
213
 
189
214
  /**
190
215
  * Adds a custom validator to the list of validation rules.
@@ -218,7 +243,7 @@ interface FieldOptions<TValue = unknown> {
218
243
  syncVModel?: boolean;
219
244
  form?: FormContext;
220
245
  }
221
- declare type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | YupValidator<TValue> | undefined;
246
+ type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | TypedSchema<TValue> | YupSchema<TValue> | undefined;
222
247
  /**
223
248
  * Creates a field composite.
224
249
  */
@@ -308,7 +333,7 @@ declare const Field: {
308
333
  };
309
334
  modelValue: {
310
335
  type: any;
311
- default: symbol;
336
+ default: any;
312
337
  };
313
338
  modelModifiers: {
314
339
  type: any;
@@ -336,8 +361,8 @@ declare const Field: {
336
361
  $slots: Readonly<{
337
362
  [name: string]: vue.Slot;
338
363
  }>;
339
- $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
340
- $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
364
+ $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
365
+ $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
341
366
  $emit: (event: string, ...args: any[]) => void;
342
367
  $el: any;
343
368
  $options: vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
@@ -387,7 +412,7 @@ declare const Field: {
387
412
  };
388
413
  modelValue: {
389
414
  type: any;
390
- default: symbol;
415
+ default: any;
391
416
  };
392
417
  modelModifiers: {
393
418
  type: any;
@@ -429,7 +454,7 @@ declare const Field: {
429
454
  rules: RuleExpression<unknown>;
430
455
  'onUpdate:modelValue': (e: any) => unknown;
431
456
  keepValue: boolean;
432
- }> & {
457
+ }, {}, string> & {
433
458
  beforeCreate?: (() => void) | (() => void)[];
434
459
  created?: (() => void) | (() => void)[];
435
460
  beforeMount?: (() => void) | (() => void)[];
@@ -444,11 +469,11 @@ declare const Field: {
444
469
  unmounted?: (() => void) | (() => void)[];
445
470
  renderTracked?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
446
471
  renderTriggered?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
447
- errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void)[];
472
+ errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void)[];
448
473
  };
449
474
  $forceUpdate: () => void;
450
475
  $nextTick: typeof vue.nextTick;
451
- $watch(source: string | Function, cb: Function, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
476
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
452
477
  } & Readonly<vue.ExtractPropTypes<{
453
478
  as: {
454
479
  type: (ObjectConstructor | StringConstructor)[];
@@ -496,7 +521,7 @@ declare const Field: {
496
521
  };
497
522
  modelValue: {
498
523
  type: any;
499
- default: symbol;
524
+ default: any;
500
525
  };
501
526
  modelModifiers: {
502
527
  type: any;
@@ -522,7 +547,7 @@ declare const Field: {
522
547
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
523
548
  [key: string]: any;
524
549
  }>[];
525
- }> & {} & vue.ComponentCustomProperties;
550
+ }> & {} & vue.ComponentCustomProperties & {};
526
551
  __isFragment?: never;
527
552
  __isTeleport?: never;
528
553
  __isSuspense?: never;
@@ -573,7 +598,7 @@ declare const Field: {
573
598
  };
574
599
  modelValue: {
575
600
  type: any;
576
- default: symbol;
601
+ default: any;
577
602
  };
578
603
  modelModifiers: {
579
604
  type: any;
@@ -615,7 +640,7 @@ declare const Field: {
615
640
  rules: RuleExpression<unknown>;
616
641
  'onUpdate:modelValue': (e: any) => unknown;
617
642
  keepValue: boolean;
618
- }> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
643
+ }, {}, string> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
619
644
  setErrors: FieldContext['setErrors'];
620
645
  setTouched: FieldContext['setTouched'];
621
646
  reset: FieldContext['resetField'];
@@ -626,16 +651,19 @@ declare const Field: {
626
651
  };
627
652
  });
628
653
 
629
- declare type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'values' | 'isSubmitting' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'controlledValues'>> & {
654
+ type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'values' | 'isSubmitting' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'resetField' | 'controlledValues'>> & {
630
655
  handleSubmit: (evt: Event | SubmissionHandler, onSubmit?: SubmissionHandler) => Promise<unknown>;
631
656
  submitForm(evt?: Event): void;
657
+ getValues<TValues extends GenericFormValues = GenericFormValues>(): TValues;
658
+ getMeta<TValues extends GenericFormValues = GenericFormValues>(): FormMeta<TValues>;
659
+ getErrors<TValues extends GenericFormValues = GenericFormValues>(): FormErrors<TValues>;
632
660
  };
633
661
  declare const Form: {
634
662
  new (...args: any[]): {
635
663
  $: vue.ComponentInternalInstance;
636
664
  $data: {};
637
665
  $props: Partial<{
638
- onSubmit: SubmissionHandler<GenericFormValues, unknown>;
666
+ onSubmit: SubmissionHandler<GenericFormValues, GenericFormValues, unknown>;
639
667
  as: string;
640
668
  initialValues: Record<string, any>;
641
669
  validateOnMount: boolean;
@@ -670,7 +698,7 @@ declare const Form: {
670
698
  default: boolean;
671
699
  };
672
700
  onSubmit: {
673
- type: PropType<SubmissionHandler<GenericFormValues, unknown>>;
701
+ type: PropType<SubmissionHandler<GenericFormValues, GenericFormValues, unknown>>;
674
702
  default: any;
675
703
  };
676
704
  onInvalidSubmit: {
@@ -691,8 +719,8 @@ declare const Form: {
691
719
  $slots: Readonly<{
692
720
  [name: string]: vue.Slot;
693
721
  }>;
694
- $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
695
- $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
722
+ $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
723
+ $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
696
724
  $emit: (event: string, ...args: any[]) => void;
697
725
  $el: any;
698
726
  $options: vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
@@ -721,7 +749,7 @@ declare const Form: {
721
749
  default: boolean;
722
750
  };
723
751
  onSubmit: {
724
- type: PropType<SubmissionHandler<GenericFormValues, unknown>>;
752
+ type: PropType<SubmissionHandler<GenericFormValues, GenericFormValues, unknown>>;
725
753
  default: any;
726
754
  };
727
755
  onInvalidSubmit: {
@@ -741,7 +769,7 @@ declare const Form: {
741
769
  [key: string]: any;
742
770
  }>[];
743
771
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
744
- onSubmit: SubmissionHandler<GenericFormValues, unknown>;
772
+ onSubmit: SubmissionHandler<GenericFormValues, GenericFormValues, unknown>;
745
773
  as: string;
746
774
  initialValues: Record<string, any>;
747
775
  validateOnMount: boolean;
@@ -750,7 +778,7 @@ declare const Form: {
750
778
  initialTouched: Record<string, any>;
751
779
  onInvalidSubmit: InvalidSubmissionHandler<GenericFormValues>;
752
780
  keepValues: boolean;
753
- }> & {
781
+ }, {}, string> & {
754
782
  beforeCreate?: (() => void) | (() => void)[];
755
783
  created?: (() => void) | (() => void)[];
756
784
  beforeMount?: (() => void) | (() => void)[];
@@ -765,11 +793,11 @@ declare const Form: {
765
793
  unmounted?: (() => void) | (() => void)[];
766
794
  renderTracked?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
767
795
  renderTriggered?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
768
- errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void)[];
796
+ errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void)[];
769
797
  };
770
798
  $forceUpdate: () => void;
771
799
  $nextTick: typeof vue.nextTick;
772
- $watch(source: string | Function, cb: Function, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
800
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
773
801
  } & Readonly<vue.ExtractPropTypes<{
774
802
  as: {
775
803
  type: StringConstructor;
@@ -796,7 +824,7 @@ declare const Form: {
796
824
  default: boolean;
797
825
  };
798
826
  onSubmit: {
799
- type: PropType<SubmissionHandler<GenericFormValues, unknown>>;
827
+ type: PropType<SubmissionHandler<GenericFormValues, GenericFormValues, unknown>>;
800
828
  default: any;
801
829
  };
802
830
  onInvalidSubmit: {
@@ -815,7 +843,7 @@ declare const Form: {
815
843
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
816
844
  [key: string]: any;
817
845
  }>[];
818
- }> & {} & vue.ComponentCustomProperties;
846
+ }> & {} & vue.ComponentCustomProperties & {};
819
847
  __isFragment?: never;
820
848
  __isTeleport?: never;
821
849
  __isSuspense?: never;
@@ -845,7 +873,7 @@ declare const Form: {
845
873
  default: boolean;
846
874
  };
847
875
  onSubmit: {
848
- type: PropType<SubmissionHandler<GenericFormValues, unknown>>;
876
+ type: PropType<SubmissionHandler<GenericFormValues, GenericFormValues, unknown>>;
849
877
  default: any;
850
878
  };
851
879
  onInvalidSubmit: {
@@ -865,7 +893,7 @@ declare const Form: {
865
893
  [key: string]: any;
866
894
  }>[];
867
895
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
868
- onSubmit: SubmissionHandler<GenericFormValues, unknown>;
896
+ onSubmit: SubmissionHandler<GenericFormValues, GenericFormValues, unknown>;
869
897
  as: string;
870
898
  initialValues: Record<string, any>;
871
899
  validateOnMount: boolean;
@@ -874,7 +902,7 @@ declare const Form: {
874
902
  initialTouched: Record<string, any>;
875
903
  onInvalidSubmit: InvalidSubmissionHandler<GenericFormValues>;
876
904
  keepValues: boolean;
877
- }> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
905
+ }, {}, string> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
878
906
  setFieldError: FormContext['setFieldError'];
879
907
  setErrors: FormContext['setErrors'];
880
908
  setFieldValue: FormContext['setFieldValue'];
@@ -882,8 +910,12 @@ declare const Form: {
882
910
  setFieldTouched: FormContext['setFieldTouched'];
883
911
  setTouched: FormContext['setTouched'];
884
912
  resetForm: FormContext['resetForm'];
913
+ resetField: FormContext['resetField'];
885
914
  validate: FormContext['validate'];
886
915
  validateField: FormContext['validateField'];
916
+ getValues: FormSlotProps['getValues'];
917
+ getMeta: FormSlotProps['getMeta'];
918
+ getErrors: FormSlotProps['getErrors'];
887
919
  $slots: {
888
920
  default: (arg: FormSlotProps) => VNode[];
889
921
  };
@@ -908,8 +940,8 @@ declare const FieldArray: {
908
940
  $slots: Readonly<{
909
941
  [name: string]: vue.Slot;
910
942
  }>;
911
- $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
912
- $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
943
+ $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
944
+ $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
913
945
  $emit: (event: string, ...args: any[]) => void;
914
946
  $el: any;
915
947
  $options: vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
@@ -923,7 +955,7 @@ declare const FieldArray: {
923
955
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
924
956
  [key: string]: any;
925
957
  }>[];
926
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}> & {
958
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string> & {
927
959
  beforeCreate?: (() => void) | (() => void)[];
928
960
  created?: (() => void) | (() => void)[];
929
961
  beforeMount?: (() => void) | (() => void)[];
@@ -938,11 +970,11 @@ declare const FieldArray: {
938
970
  unmounted?: (() => void) | (() => void)[];
939
971
  renderTracked?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
940
972
  renderTriggered?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
941
- errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void)[];
973
+ errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void)[];
942
974
  };
943
975
  $forceUpdate: () => void;
944
976
  $nextTick: typeof vue.nextTick;
945
- $watch(source: string | Function, cb: Function, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
977
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
946
978
  } & Readonly<vue.ExtractPropTypes<{
947
979
  name: {
948
980
  type: StringConstructor;
@@ -954,7 +986,7 @@ declare const FieldArray: {
954
986
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
955
987
  [key: string]: any;
956
988
  }>[];
957
- }> & {} & vue.ComponentCustomProperties;
989
+ }> & {} & vue.ComponentCustomProperties & {};
958
990
  __isFragment?: never;
959
991
  __isTeleport?: never;
960
992
  __isSuspense?: never;
@@ -969,7 +1001,7 @@ declare const FieldArray: {
969
1001
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
970
1002
  [key: string]: any;
971
1003
  }>[];
972
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1004
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
973
1005
  push: FieldArrayContext['push'];
974
1006
  remove: FieldArrayContext['remove'];
975
1007
  swap: FieldArrayContext['swap'];
@@ -1011,8 +1043,8 @@ declare const ErrorMessage: {
1011
1043
  $slots: Readonly<{
1012
1044
  [name: string]: vue.Slot;
1013
1045
  }>;
1014
- $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
1015
- $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>;
1046
+ $root: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
1047
+ $parent: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>;
1016
1048
  $emit: (event: string, ...args: any[]) => void;
1017
1049
  $el: any;
1018
1050
  $options: vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
@@ -1034,7 +1066,7 @@ declare const ErrorMessage: {
1034
1066
  }>[];
1035
1067
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1036
1068
  as: string;
1037
- }> & {
1069
+ }, {}, string> & {
1038
1070
  beforeCreate?: (() => void) | (() => void)[];
1039
1071
  created?: (() => void) | (() => void)[];
1040
1072
  beforeMount?: (() => void) | (() => void)[];
@@ -1049,11 +1081,11 @@ declare const ErrorMessage: {
1049
1081
  unmounted?: (() => void) | (() => void)[];
1050
1082
  renderTracked?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
1051
1083
  renderTriggered?: ((e: vue.DebuggerEvent) => void) | ((e: vue.DebuggerEvent) => void)[];
1052
- errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>>, info: string) => boolean | void)[];
1084
+ errorCaptured?: ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void) | ((err: unknown, instance: vue.ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, vue.ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string>, {}>, info: string) => boolean | void)[];
1053
1085
  };
1054
1086
  $forceUpdate: () => void;
1055
1087
  $nextTick: typeof vue.nextTick;
1056
- $watch(source: string | Function, cb: Function, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
1088
+ $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
1057
1089
  } & Readonly<vue.ExtractPropTypes<{
1058
1090
  as: {
1059
1091
  type: StringConstructor;
@@ -1071,7 +1103,7 @@ declare const ErrorMessage: {
1071
1103
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
1072
1104
  [key: string]: any;
1073
1105
  }>[];
1074
- }> & {} & vue.ComponentCustomProperties;
1106
+ }> & {} & vue.ComponentCustomProperties & {};
1075
1107
  __isFragment?: never;
1076
1108
  __isTeleport?: never;
1077
1109
  __isSuspense?: never;
@@ -1094,21 +1126,22 @@ declare const ErrorMessage: {
1094
1126
  }>[];
1095
1127
  }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1096
1128
  as: string;
1097
- }> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1129
+ }, {}, string> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1098
1130
  $slots: {
1099
1131
  default: (arg: ErrorMessageSlotProps) => VNode[];
1100
1132
  };
1101
1133
  });
1102
1134
 
1103
- interface FormOptions<TValues extends Record<string, any>> {
1104
- validationSchema?: MaybeRef<Record<keyof TValues, GenericValidateFunction | string | Record<string, any>> | any | undefined>;
1135
+ type FormSchema<TValues> = Record<keyof TValues, GenericValidateFunction | string | GenericFormValues> | undefined;
1136
+ interface FormOptions<TValues extends GenericFormValues, TOutput extends TValues = TValues, TSchema extends TypedSchema<TValues, TOutput> | FormSchema<TValues> = FormSchema<TValues> | TypedSchema<TValues, TOutput>> {
1137
+ validationSchema?: MaybeRef<TSchema extends TypedSchema ? TypedSchema<TValues, TOutput> : any>;
1105
1138
  initialValues?: MaybeRef<TValues>;
1106
1139
  initialErrors?: Record<keyof TValues, string | undefined>;
1107
1140
  initialTouched?: Record<keyof TValues, boolean>;
1108
1141
  validateOnMount?: boolean;
1109
1142
  keepValuesOnUnmount?: MaybeRef<boolean>;
1110
1143
  }
1111
- declare function useForm<TValues extends Record<string, any> = Record<string, any>>(opts?: FormOptions<TValues>): FormContext<TValues>;
1144
+ declare function useForm<TValues extends GenericFormValues = GenericFormValues, TOutput extends TValues = TValues, TSchema extends FormSchema<TValues> | TypedSchema<TValues, TOutput> = FormSchema<TValues> | TypedSchema<TValues, TOutput>>(opts?: FormOptions<TValues, TOutput, TSchema>): FormContext<TValues, TOutput>;
1112
1145
 
1113
1146
  declare function useFieldArray<TValue = unknown>(arrayPath: MaybeRef<string>): FieldArrayContext<TValue>;
1114
1147
 
@@ -1188,6 +1221,6 @@ declare function useSubmitForm<TValues extends Record<string, unknown> = Record<
1188
1221
 
1189
1222
  declare const FormContextKey: InjectionKey<PrivateFormContext>;
1190
1223
  declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1191
- declare const IS_ABSENT: unique symbol;
1224
+ declare const IS_ABSENT: any;
1192
1225
 
1193
- export { ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InvalidSubmissionContext, InvalidSubmissionHandler, RuleExpression, SubmissionContext, SubmissionHandler, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate };
1226
+ export { ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, FieldState, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InvalidSubmissionContext, InvalidSubmissionHandler, RawFormSchema, RuleExpression, SubmissionContext, SubmissionHandler, TypedSchema, TypedSchemaError, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };