conform icon indicating copy to clipboard operation
conform copied to clipboard

conform does strict validation inspite of `schema.passthrough()`

Open IgnisDa opened this issue 11 months ago • 2 comments

Describe the bug and the expected behavior

I have the following schema:

const schema = z.object({
	email: z.string().email(),
	message: z.string(),
});

But my FormData contains the following fields:

{"email": "[email protected]","message":"msg1","honeypot":"val"}

It seems like conform does strict validation on the schema. Ideally, I would like it to ignore the fields that are not in the schema. Instead i get honeypot: expected never: got string.

Would it be possible to add an option to parseWithZod to support non strict schemas?

Conform version

v1.2.2

Steps to Reproduce the Bug or Issue

As described above.

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

IgnisDa avatar Jan 22 '25 17:01 IgnisDa

Hi, I also notice this. In previous versions this wasn't the default behaviour. It is expected to be this the new behaviour or is a bug in the newer versions?

Thanks and regards

Mat-moran avatar Feb 11 '25 12:02 Mat-moran

In previous versions this wasn't the default behaviour.

Interesting. I don't think there is any changes made on our side for a while. I wonder if this is a change on the zod side. Which zod version are you using?

edmundhung avatar Feb 22 '25 00:02 edmundhung