-
-
Notifications
You must be signed in to change notification settings - Fork 338
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] Field validation from form schema #925
Conversation
# Conflicts: # packages/react-form/src/nextjs/createServerValidate.ts # packages/react-form/src/start/createServerValidate.tsx
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 198c08a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for jumping so fast on expanding adapters to the new validation API :D
IIRC @jljorgenson18 was also looking for this feature, feedback is welcome!
Yep I was going to try to contribute here and was waiting for the field error set from form PR to be merged. I'm happy to give feedback and try it out at least. |
What is the current status of this PR? |
@bompi88 I'm... Actively working on it? Like, have made commit less than an hour ago that marked a lot of things off? We'll get it reviewed soon, but timing just felt weird with "status?" right after I'd worked on it lol |
@crutchcorn I'm sorry I did not see that. I agree that is weird 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All three adapters now should be able to inject errors for:
- Primitives
- Nested objects
- Arrays
A couple extra notes:
- I kinda went bruteforce when adapting each validator's path system into our own and used the exact same approach on all of them. Pros, easier to maintain, cons, there might be a smarter (faster?) way for each validator (e.g. zod has a flatten function, could it help? I don't know)
- There's quite a lot of repeated code across the validators. Are we ok keeping it like that or refactoring a bit?
Anyway, I don't think these are blockers. We now have the feature working without any breaking change to our API, there's plenty of time to refine the internals later imho.
🚀 |
This LGTM @Balastrong - great work! Merging now |
@crutchcorn Nice work! I love to test it out 😁 I think the squash commit message was on the wrong format |
* feat: add ability to pass errors to specific fields from Zod * chore: code cleanup * chore: fix various issues * chore: more TSC and lib fixes * ci: apply automated fixes * feat: add Yup support to schema valdiation * chore: rename contexts from code review * ci: apply automated fixes * feat: support form validaton in Valibot * chore: fix tests for createServerValidate * docs: add docs for validation logic * feat: apply transformError to all fields * fix: set transformed errors on nested fields * feat: spread zod errors into arrays * feat: spread yup errors into fields, nested and arrays * feat: spread valibot errors into fields, nested and arrays --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
@bompi88 you're right! :D I fixed it now, 0.33 should be available 🚀 |
Thanks @Balastrong and @crutchcorn ! So far this version works really well🎉 |
This PR introduces the ability to pass a schema to the
validators
object on a form and have it validate each specific field:TODO
createServerValidate