react-hook-form / resolvers

📋 Validation resolvers: Yup, Zod, Superstruct, Joi, Vest, Class Validator, io-ts, Nope, computed-types, typanion, Ajv, TypeBox, ArkType, Valibot, effect-ts and VineJS
https://react-hook-form.com/
MIT License
1.71k stars 155 forks source link

[valibot 🤖]: Cannot conditionally require a field without freezing web page #628

Closed demarchenac closed 1 month ago

demarchenac commented 11 months ago

Describe the bug

As the title states, I'm just trying to conditionally require a field via the object() pipeline with valibot. I just so happens that the web page freezes when doing so.

To Reproduce

It's easy to reproduce since I have a working example on StackBlitz.

Basically, the way to trigger this bug is to modify the Required Input whenever any of the other three inputs doesn't have a value, if I were to fill those three up, modifying the Required Input doesn't freeze the web view.

Expected behavior

I should be able to conditionally require a field within a form depending on other fields.

Desktop (please complete the following information):

Additional context

I've also added up to a related issue within the valibot repo

irg1008 commented 11 months ago

Happens to me as well, makes object checks like sibling field equality impossible

demarchenac commented 11 months ago

Well, it ain't impossible, we need to create custom pipeline methods as shown in the following valibot issues:

But it's really weird that the custom pipeline method breakes the application when being used on object schemas

jorisre commented 1 month ago

@demarchenac, has your issue been resolved?

demarchenac commented 1 month ago

@jorisre I managed to find a work-around avoiding the usage of custom, also this seems to be fixed on further releases