Skip to content

Commit

Permalink
fix: clone the schema object before validating closes #4459
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 9, 2023
1 parent 5231f43 commit 8f680bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/red-penguins-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vee-validate': patch
---

fix: clone the schema object before validating closes #4459
3 changes: 2 additions & 1 deletion packages/vee-validate/src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolveRule } from './defineRule';
import { klona as deepCopy } from 'klona/full';
import { isLocator, normalizeRules, keysOf, getFromPath, isTypedSchema, isYupValidator } from './utils';
import { getConfig } from './config';
import {
Expand Down Expand Up @@ -299,7 +300,7 @@ export async function validateTypedSchema<TValues, TOutput = TValues>(
values: TValues,
): Promise<FormValidationResult<TValues, TOutput>> {
const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
const validationResult = await typedSchema.parse(values);
const validationResult = await typedSchema.parse(deepCopy(values));

const results: Partial<Record<Path<TValues>, ValidationResult>> = {};
const errors: Partial<Record<Path<TValues>, string>> = {};
Expand Down

0 comments on commit 8f680bf

Please sign in to comment.