foxhound87 / mobx-react-form

Reactive MobX Form State Management
https://foxhound87.github.io/mobx-react-form
MIT License
1.09k stars 129 forks source link

Yup validation "branch is not a function" also "yup.ref" not working correctly #626

Open sajera opened 1 year ago

sajera commented 1 year ago

The "yup" validation is not working correctly. Please take a look at example

Sandbox

foxhound87 commented 1 year ago

Hello, how can I replicate this issue branch is not a function? The yup.ref could not be available currently. Use related prop correctly. The field related prop cannot be a boolean, it accepts an array of the paths of the related fields.

sajera commented 1 year ago

There is a comment on how to replicate it. Here line 744-785.

The property related doesn't make any sense in this issue. That was different experiments within that Sandbox.

"The yup.ref could not be available currently" - means this YUP integration is useless because no way to validate related fields using yup. That's sad to know 😭

foxhound87 commented 1 year ago

branch is not a function should be related to yup package, the version 1 has changes. Try to use a function on then and otherwise props:

password: yup.string().when("email", {
  is: true,
  then: () => yup.string().required(),
  otherwise: () => yup.string()
}),

about the yup.ref function, I have to figure out how to implement it in the driver.

foxhound87 commented 1 year ago

I also checked the driver code and I cant' find a solution to the yup.ref function. I think this should already work and could be an issue of yup itself.

sajera commented 1 year ago

Seems weird. That solution was taken from the another project with another technologies and work fine there. At any case thank you, for your investigation. Feel free to close the issue due to absent solutions or improvements around it.

At any cases the relations between fields not working as expected with "yup" it's too sad.

.when and .ref - implement ability to change validation rules based on current form values of other fields. Means they can't work if you trying to check fields values separated or partially.