Skip to content

Commit c02337f

Browse files
committed
fix(types): setErrors should allow array of strings closes #4396
1 parent 5d4ccec commit c02337f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/bright-eels-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vee-validate': patch
3+
---
4+
5+
fix: correct the setErrors type to allow for string[]

packages/vee-validate/src/types/forms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComputedRef, Ref, MaybeRef, MaybeRefOrGetter } from 'vue';
2-
import { MapValuesPathsToRefs, GenericObject, MaybeArray, MaybePromise } from './common';
2+
import { MapValuesPathsToRefs, GenericObject, MaybeArray, MaybePromise, FlattenAndSetPathsType } from './common';
33
import { FieldValidationMetaInfo } from '../../../shared';
44
import { Path, PathValue } from './paths';
55
import { PartialDeep } from 'type-fest';
@@ -167,7 +167,7 @@ export type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TV
167167
export interface FormActions<TValues extends GenericObject, TOutput = TValues> {
168168
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
169169
setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
170-
setErrors(fields: FormErrors<TValues>): void;
170+
setErrors(fields: Partial<FlattenAndSetPathsType<TValues, string | string[] | undefined>>): void;
171171
setValues(fields: PartialDeep<TValues>, shouldValidate?: boolean): void;
172172
setFieldTouched(field: Path<TValues>, isTouched: boolean): void;
173173
setTouched(fields: Partial<Record<Path<TValues>, boolean>>): void;

0 commit comments

Comments
 (0)