Comments (11)
@fabian-hiller, it looks like someone else was quicker in opening a pull request.
The resolver has already been released. 🎉
from valibot.
Just new about this library a few days ago this would make its usage skyrocket for sure with a resolver for react-hook-form great work with it 🥇
from valibot.
If someone wants to help with this, just contact me here.
I could take a look later today
from valibot.
I'll have some time on my hands tomorrow and continue working on it 🙂
from valibot.
@lucaschultz thanks a lot for working on the React Hook Form resolver 💙
from valibot.
I will have a look at it as soon as I have time. If someone wants to help with this, just contact me here.
from valibot.
Thank you @lucaschultz! Have a look at the ValiError
class and maybe it helps to have a look at the adapter I built for Modular Forms. If needed you can use flatten
to convert the errors to a dot path object.
from valibot.
@lucaschultz are there any updates about the resolver for React Form Hook?
from valibot.
Okay, I got a prototype working. Have a look at this file for the source and this file to see it in action. I'm using it very similar to how I would use a Zod schema including importing it as v
. You can play around with the deployed version here. Of course the idea is to add it to the hook form resolvers. But I needed a playground first.
I was wondering about the issues
property of the ValiError
. Does it contain sub issues? It does not seem to be used when e.g. a string fails multiple validations?
Also:
- Does Valibot support preprocessing and/or refinements?
- Does it support catchall schemas on objects?
- The default error messages don't really lend themselves as validation messages. Zod has the concept of custom error maps which we use at work to get validation messages from out language files. Is there such a concept yet or do all the messages have to be defined alongside the form schema?
Sorry for the questions. I had no time to have a closer look at the source. Great work on Valibot 😊
from valibot.
Here I would, to be on the safe side, not use a wildcard import, because I don't know if every bundler can still split the code.
Here you can simplify the code and change it to the following. Normally I recommend not to use schema.parse
because it is an internal API of Valibot. But in this use case it is ok to reduce the code and the bundle size.
const data = await schema.parse(values);
from valibot.
I was wondering about the issues property of the ValiError. Does it contain sub issues?
This could be related with issue #18. What behavior from Valibot would you expect here. I think by default Valibot behaves almost the same as Zod here.
Does Valibot support preprocessing and/or refinements?
Yes, preprocessing with coerce
and refinements with our pipeline feature eg. with custom
or any custom code.
Does it support catchall schemas on objects?
No, not yet. You are welcome to create an issue for this feature.
The default error messages don't really lend themselves as validation messages. Zod has the concept of ...
Currently Valibot does not support this yet. Please create a new issue and send me a pseudo sample code with your desired API.
from valibot.
Related Issues (20)
- [Proposal] Considering Biome for formating and linting HOT 1
- Branded schema doesn't provide the type guard thru the `is`. HOT 2
- Add CIDR Schema Type HOT 3
- Reporting of Errors (ValiError Format compared with ZodError Format) HOT 3
- Nullable, how can i do
- isoTimestamp only supports decimal fraction up to 3 digits HOT 8
- Cannot use `brand` with `url` or `email` HOT 1
- Document minimum typescript version HOT 7
- Nextjs build Failed HOT 6
- How can I define a schema so that it can be validated as a function? HOT 1
- getDefaults returns undefined for optional with a default of empty string or false HOT 2
- The validation of the object is not rigorous enough HOT 3
- Optional Objects with Literal Fields and Raw Default Result in "| undefined" Type HOT 1
- union(): Union wrong behavior when type validation pass HOT 2
- A GPT companion for the Zod to Valibot conversion HOT 1
- `union()` of object with overlapping field drops other fields HOT 4
- Supporte Metadata like description
- Support non-string array in `picklist` HOT 4
- customAsync not resolved inside issues? HOT 4
- Change omit() parameter type to `readonly TKeys[]` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valibot.