when function
- IValidator condition, {
- required IValidator then,
- required IValidator otherwise,
Creates a conditional validator. It's conditional based on some other field in the eskema.
The condition validator is run against the parent map.
- If the condition is met,
thenis used to validate the current field's value. - If the condition is not met,
otherwiseis used.
Implementation
IValidator when(
IValidator condition, {
required IValidator then,
required IValidator otherwise,
}) {
return WhenValidator(condition, then, otherwise);
}