From 638f5b35d10935d95d778530f2df16df4ecae4f5 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Tue, 14 Jan 2025 22:02:30 +0100 Subject: [PATCH 1/2] fix(Form): standard schema validation no longer wrapped in `value` object --- src/runtime/utils/form.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/runtime/utils/form.ts b/src/runtime/utils/form.ts index e2ba4329aa..249731b241 100644 --- a/src/runtime/utils/form.ts +++ b/src/runtime/utils/form.ts @@ -47,9 +47,7 @@ export async function validateStandardSchema( state: any, schema: StandardSchemaV1 ): Promise> { - const result = await schema['~standard'].validate({ - value: state - }) + const result = await schema['~standard'].validate(state) if (result.issues) { return { @@ -63,7 +61,7 @@ export async function validateStandardSchema( return { errors: null, - result: result.value + result } } From 174fcc3911b7797502ec2f48de24deb2297081c9 Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Wed, 15 Jan 2025 22:19:18 +0100 Subject: [PATCH 2/2] fix: unpack result value --- src/runtime/utils/form.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/utils/form.ts b/src/runtime/utils/form.ts index 249731b241..160ba8f8b7 100644 --- a/src/runtime/utils/form.ts +++ b/src/runtime/utils/form.ts @@ -61,7 +61,7 @@ export async function validateStandardSchema( return { errors: null, - result + result: result.value } } @@ -195,14 +195,14 @@ export function validateSchema(state: T, schema: FormSchema return validateZodSchema(state, schema) } else if (isJoiSchema(schema)) { return validateJoiSchema(state, schema) + } else if (isStandardSchema(schema)) { + return validateStandardSchema(state, schema) } else if (isValibotSchema(schema)) { return validateValibotSchema(state, schema) } else if (isYupSchema(schema)) { return validateYupSchema(state, schema) } else if (isSuperStructSchema(schema)) { return validateSuperstructSchema(state, schema) - } else if (isStandardSchema(schema)) { - return validateStandardSchema(state, schema) } else { throw new Error('Form validation failed: Unsupported form schema') }