AbstractAbstractuseAdds a validation rule to the schema's validation chain. Must be implemented by the extending class.
The validation rule or rule builder to add
Marks the field as required when a condition is met. Can be used with a callback or with comparison operators to compare another field's value.
Field name to compare or callback function
Comparison operator (=, !=, in, notIn, >, <, >=, <=)
Expected value to compare against
Marks the field as required when a condition is met. Can be used with a callback or with comparison operators to compare another field's value.
Marks the field as required when all specified fields exist (are not undefined or null).
Field name or array of field names to check for existence
Marks the field as required when any one of the specified fields exists (is not undefined or null).
Array of field names to check for existence
Marks the field as required when all specified fields are missing (undefined or null).
Field name or array of field names to check for absence
Marks the field as required when any one of the specified fields is missing (undefined or null).
Array of field names to check for absence
Abstract base class providing conditional validation methods for making fields required based on runtime conditions. This class is extended by schema types that support conditional validation.
Example