'Why yup validation is not working when matched for a specific value?
I have a scenario where I have to put a check on a field (btext) value based on another field's (aText) value. The check will only be applicable when the other field has its value equal to a predefined reference value (predefinedValue). Below is my yup validation code
export const bText = yup
.string()
.when("aText", aText => {
if (aText === predefinedValue) {
console.log("its here");
return yup.string().required("Required");
} else return yup.string();
});
The validation works when pre-defined value is matched and bText is left unfilled. But even if bText is filled the validation doesn't pass. Where am I going wrong ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
