ValidatorBuilder<T> class

A validator that uses a custom builder function for validation logic.

ValidatorBuilder provides a flexible way to create validators using inline functions or custom validation logic without extending the Validator class.

Example:

ValidatorBuilder<String>(
  (value) {
    if (value != null && value.contains('@')) {
      return null; // Valid
    }
    return InvalidResult('Must contain @');
  },
)
Inheritance

Constructors

ValidatorBuilder(ValidatorBuilderFunction<T> builder, {List<FormKey> dependencies = const []})
Creates a ValidatorBuilder with the specified builder function.
const

Properties

builder ValidatorBuilderFunction<T>
The function that performs the validation.
final
dependencies List<FormKey>
List of form field keys this validator depends on.
final
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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.
override
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