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
Constructors
- Validator.custom(bool isValidCallback(S state))
-
Creates a validator with custom logic.
constfactory
- Validator.exactLength(int value)
-
Validates exact length for strings/iterables.
constfactory
- Validator.maxLength(int value)
-
Validates maximum length for strings/iterables.
constfactory
- Validator.minLength(int value)
-
Validates minimum length for strings/iterables.
constfactory
- Validator.required()
-
Validates that the value is not empty/null.
constfactory
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