-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat(conform-dom,conform-react,conform-zod,conform-yup)!: server validation #40
Conversation
Deploying with
|
Latest commit: |
6586bae
|
Status: | ✅ Deploy successful! |
Preview URL: | https://35563a94.conform.pages.dev |
Branch Preview URL: | https://simplify-validation.conform.pages.dev |
Does async validation land in this? |
Hi @brandonpittman! Maybe. (update: Maybe not in this PR but definitely in the coming release.) I have a working prototype locally already but I am still refining the API surface. The new validation flow changes quite many things internally and I am trying to break it down into smaller chunks. Anyway, I am planning to cut a release by the end of this week (or a pre-release depends on the progress). The current PR replaces the For example, you can find how to manually validate a login form with the new approach here. It no longer couples with the schema resolver with the error simplifies to // Before
const submission = schema.parse(formData);
const state = submission.form;
// After
const state = parse(formData)
const result = schema.safeParse(state.value);
if (!result.success) {
// getError is a new util provided by `conform-to/zod`, which returns Array<[string, string]>
state.error = state.error.concat(getError(result.error));
} There will also be some mindset change on how validation is done in the new version. It is not pushed to this branch yet. But the idea would be making server validation the default and you are progressively enhancing it with optional client side validation (which works/acts like a middleware). The adjustment hopefully will reflect this idea 🔥 |
@edmundhung That sounds great to me. I may be jumping the gun, but I'm using Conform in a production app that will ship in December. |
Oh man, @brandonpittman. I am so grateful for your support on this project. Is there any other pain-points you are having with conform? I will be focusing on improving the tests coverage after this release but if there is anything I can prioritise to support you better, let me know. |
@edmundhung As of now, the parseAsync thing (I worked around it but it would be cleaner if Conform had its own parseAsync) and the other issue with shadow inputs that aren’t Conform shadow inputs. |
If you are referring to |
Hi @brandonpittman, I have just published |
Note: The API surface on |
@edmundhung Thanks! I'll take a look at it. |
I'd have success using |
Context
This PR redesigns the validation flow and make conform a server-validation first solution.
Documentation will be added in another PR and all changed would be detailed in the release note soon.
Example
Try it out on Codesandbox