Skip to content

Commit

Permalink
fix(types): setErrors should allow array of strings closes #4396
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Jul 29, 2023
1 parent 5d4ccec commit c02337f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-eels-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vee-validate': patch
---

fix: correct the setErrors type to allow for string[]
4 changes: 2 additions & 2 deletions packages/vee-validate/src/types/forms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComputedRef, Ref, MaybeRef, MaybeRefOrGetter } from 'vue';
import { MapValuesPathsToRefs, GenericObject, MaybeArray, MaybePromise } from './common';
import { MapValuesPathsToRefs, GenericObject, MaybeArray, MaybePromise, FlattenAndSetPathsType } from './common';
import { FieldValidationMetaInfo } from '../../../shared';
import { Path, PathValue } from './paths';
import { PartialDeep } from 'type-fest';
Expand Down Expand Up @@ -167,7 +167,7 @@ export type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TV
export interface FormActions<TValues extends GenericObject, TOutput = TValues> {
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
setErrors(fields: FormErrors<TValues>): void;
setErrors(fields: Partial<FlattenAndSetPathsType<TValues, string | string[] | undefined>>): void;
setValues(fields: PartialDeep<TValues>, shouldValidate?: boolean): void;
setFieldTouched(field: Path<TValues>, isTouched: boolean): void;
setTouched(fields: Partial<Record<Path<TValues>, boolean>>): void;
Expand Down

0 comments on commit c02337f

Please sign in to comment.