ConditionalValidator<T> class

ConditionalValidator extends BaseValidator to conditionally validate a value based on a provided condition.

Parameters:

  • condition A function that returns a boolean indicating whether the validator should be applied.
  • validator The validator to apply if the condition is met.
  • checkNullOrEmpty Whether to check if the value is null or empty. This is set to false by default.
Inheritance

Constructors

ConditionalValidator(bool condition(T? value), FormFieldValidator<T> validator)
Constructor for the conditional validator.
const

Properties

checkNullOrEmpty → bool
Whether to check if the value is null or empty.
finalinherited
condition → bool Function(T? value)
A function that returns a boolean indicating whether the validator should be applied.
final
errorText → String?
The error message returned if the value is invalid.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
validator → FormFieldValidator<T>
The validator to apply if the condition is met.
final

Methods

isNullOrEmpty(T? valueCandidate) → bool
Checks if the value is null or empty. Returns true if the value is null or empty, otherwise false. The value is considered empty if it is a String, Iterable, or Map and it is empty or contains only whitespace characters. If the value is not a String, Iterable, or Map, it is considered empty if it is null.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
validate(T? valueCandidate) → String?
Validates the value and checks if it is null or empty.
override
validateValue(T? valueCandidate) → String?
Validates the value. Returns null if the value is valid, otherwise an error message. Call validate() instead of this method when using the validator.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited