Skip to content

Commit

Permalink
fix: exclude undefined and null from initial values closes #4139
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed May 17, 2023
1 parent 7e85ff1 commit f4ea2c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-taxis-kiss.md
@@ -0,0 +1,5 @@
---
'vee-validate': patch
---

fix: exclude undefined and null from initial values closes #4139
6 changes: 4 additions & 2 deletions packages/vee-validate/src/useForm.ts
Expand Up @@ -83,7 +83,7 @@ export interface FormOptions<
| TypedSchema<TValues, TOutput>
> {
validationSchema?: MaybeRef<TSchema extends TypedSchema ? TypedSchema<TValues, TOutput> : any>;
initialValues?: MaybeRef<PartialDeep<TValues>>;
initialValues?: MaybeRef<PartialDeep<TValues> | undefined | null>;
initialErrors?: FlattenAndSetPathsType<TValues, string | undefined>;
initialTouched?: FlattenAndSetPathsType<TValues, boolean>;
validateOnMount?: boolean;
Expand Down Expand Up @@ -1066,7 +1066,9 @@ function useFormInitialValues<TValues extends GenericObject>(
watch(
providedValues,
value => {
setInitialValues(value, true);
if (value) {
setInitialValues(value, true);
}
},
{
deep: true,
Expand Down

0 comments on commit f4ea2c0

Please sign in to comment.