when function

IValidator when(
  1. IValidator condition, {
  2. required IValidator then,
  3. 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, then is used to validate the current field's value.
  • If the condition is not met, otherwise is used.

Implementation

IValidator when(
  IValidator condition, {
  required IValidator then,
  required IValidator otherwise,
}) {
  return WhenValidator(condition, then, otherwise);
}