Skip to content

CoerceFormValue breaks superRefine method on schema #1102

@leonardo-ornelas

Description

@leonardo-ornelas

Describe the bug and the expected behavior

When wrapping a Zod schema with coerceFormValue(), the returned schema loses the superRefine method, causing a runtime error: TypeError: RecordPaymentSchema.superRefine is not a function

Conform version

v1.13.3

Steps to Reproduce the Bug or Issue

Define a Zod schema and wrap it with coerceFormValue:

import { coerceFormValue } from '@conform-to/zod/v4/future'
const RecordPaymentSchema = coerceFormValue(z.object({ /* fields */ }))

Try to call .superRefine() on the wrapped schema in the action:

const submission = await parseWithZod(formData, {
    schema: RecordPaymentSchema.superRefine(async (data, ctx) => { /* ... */ }),
    async: true,
})

Expected Behavior

The schema should support .superRefine() method for adding validation logic, as it does with unwrapped Zod schemas.

Actual Behavior
Runtime error: TypeError: RecordPaymentSchema.superRefine is not a function

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions