In case your form has multiple sections, and some of them is may be disabled and need not to be validated at all, then Bee Form's config condition can help.
For example:
import {createForm, condition, ...} from "bee-form-react";
createForm([
{
"sex": [either("male", "female")],
},
condition((data) => data.sex === "female", {
"pregnant": [required, either(true, false)],
})
])
With this sample, there are a few changes to original form config:
condition
from "bee-form-react"While running this sample, we will see that the field "pregnant" will only be validated (with required
and either
) when "sex" is set to "female". If "sex" is set to "male", "pregnant" field is irrelevant, no validation will be run against it.