Validator<S> class sealed

Base class for all validators.

Validators check if a state value meets certain criteria. They return true for valid, false for invalid.

Example:

const validator = Validator.required();
validator.isValid('hello'); // true
validator.isValid('');      // false
Implementers

Constructors

Validator.custom(bool isValidCallback(S state))
Creates a validator with custom logic.
const
factory
Validator.exactLength(int value)
Validates exact length for strings/iterables.
const
factory
Validator.maxLength(int value)
Validates maximum length for strings/iterables.
const
factory
Validator.minLength(int value)
Validates minimum length for strings/iterables.
const
factory
Validator.required()
Validates that the value is not empty/null.
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isValid(S state) bool
Returns true if the state is valid according to this validator's rules.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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