Skip to content

Commit 8f680bf

Browse files
committed
fix: clone the schema object before validating closes #4459
1 parent 5231f43 commit 8f680bf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/red-penguins-impress.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: clone the schema object before validating closes #4459

packages/vee-validate/src/validate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { resolveRule } from './defineRule';
2+
import { klona as deepCopy } from 'klona/full';
23
import { isLocator, normalizeRules, keysOf, getFromPath, isTypedSchema, isYupValidator } from './utils';
34
import { getConfig } from './config';
45
import {
@@ -299,7 +300,7 @@ export async function validateTypedSchema<TValues, TOutput = TValues>(
299300
values: TValues,
300301
): Promise<FormValidationResult<TValues, TOutput>> {
301302
const typedSchema = isTypedSchema(schema) ? schema : yupToTypedSchema(schema);
302-
const validationResult = await typedSchema.parse(values);
303+
const validationResult = await typedSchema.parse(deepCopy(values));
303304

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

0 commit comments

Comments
 (0)