Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alex-pirogov opened this issue Nov 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@alex-pirogov
Copy link

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

@alex-pirogov alex-pirogov added the enhancement New feature or request label Nov 21, 2024
@ciscoheat
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants