Git Product home page Git Product logo

Comments (11)

lucaschultz avatar lucaschultz commented on May 22, 2024 6

@fabian-hiller, it looks like someone else was quicker in opening a pull request.

The resolver has already been released. 🎉

from valibot.

joaopedrodcf avatar joaopedrodcf commented on May 22, 2024 4

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.

lucaschultz avatar lucaschultz commented on May 22, 2024 3

If someone wants to help with this, just contact me here.

I could take a look later today

from valibot.

lucaschultz avatar lucaschultz commented on May 22, 2024 3

I'll have some time on my hands tomorrow and continue working on it 🙂

from valibot.

fabian-hiller avatar fabian-hiller commented on May 22, 2024 2

@lucaschultz thanks a lot for working on the React Hook Form resolver 💙

from valibot.

fabian-hiller avatar fabian-hiller commented on May 22, 2024 1

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.

fabian-hiller avatar fabian-hiller commented on May 22, 2024 1

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.

fabian-hiller avatar fabian-hiller commented on May 22, 2024 1

@lucaschultz are there any updates about the resolver for React Form Hook?

from valibot.

lucaschultz avatar lucaschultz commented on May 22, 2024

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.

fabian-hiller avatar fabian-hiller commented on May 22, 2024

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.

fabian-hiller avatar fabian-hiller commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.