ValidationMode<T> class

A validator wrapper that controls when validation occurs based on form lifecycle.

ValidationMode wraps another validator and only executes it during specific validation modes. This allows fine-grained control over when validation rules are applied during the form lifecycle (initial load, value changes, submission).

Example:

ValidationMode(
  EmailValidator(),
  mode: {FormValidationMode.changed, FormValidationMode.submitted},
)
Inheritance

Constructors

ValidationMode(Validator<T> validator, {Set<FormValidationMode> mode = const {FormValidationMode.changed, FormValidationMode.submitted, FormValidationMode.initial}})
Creates a ValidationMode that conditionally validates based on lifecycle mode.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
mode Set<FormValidationMode>
The set of validation modes during which this validator should run.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validator Validator<T>
The underlying validator to execute when mode conditions are met.
final

Methods

combine(Validator<T> other) Validator<T>
Combines this validator with another validator using AND logic.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRevalidate(FormKey source) bool
Determines if this validator should be re-run when the specified form key changes.
inherited
toString() String
A string representation of this object.
inherited
validate(BuildContext context, T? value, FormValidationMode lifecycle) FutureOr<ValidationResult?>
Validates the given value and returns a validation result.
override

Operators

operator &(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator +(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator ==(Object other) bool
The equality operator.
override
operator unary-() Validator<T>
Negates this validator's result (alias for ~ operator).
inherited
operator |(Validator<T> other) Validator<T>
Combines this validator with another using OR logic.
inherited
operator ~() Validator<T>
Negates this validator's result.
inherited