sveltekit-superforms
sveltekit-superforms copied to clipboard
return data from adapter's `validate` even if validation isn't successful
Is your feature request related to a problem? Please describe. I'm using valibot adapter which also supports transformations. Consider the schema:
const schema = v.object({
email: v.pipe(v.string(), v.trim(), v.toLowerCase(), v.email())
})
If my form's data looks like this:
{ email: ' foobar' }
then validation obviously fails, but transformations are not applied as data is returned only if validation is successful. Valibot's validation result at the same time is:
output: {
email: "foobar"
}
Describe the solution you'd like In some cases it would be great to apply invalid validation output to form data. This will allow easily create forms which modify user's input on-the-fly
This is how all adapters and validation libraries work, the idea is that you want to preserve user data to avoid surprises. Modifying data before the submit process is successful can produce a worse UX. But of course there are exceptions, so if you'd like to do that, I suggest making a separate validation with the schema itself.