ciscoheat / sveltekit-superforms

Making SvelteKit forms a pleasure to use!
https://superforms.rocks
MIT License
2.26k stars 66 forks source link

return data from adapter's `validate` even if validation isn't successful #512

Open alex-pirogov opened 1 week ago

alex-pirogov commented 1 week ago

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