IValidator class abstract
Inmutable class from which all validators inherit.
You can use it to create custom validators, but consider using other ways of creating custom validators (see Custom Validators)
Or consider using one of the validators for built in validation.
- Implementers
- Available extensions
Constructors
- IValidator.new({bool nullable = false, bool optional = false})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isNullable → bool
-
Marks the validator as nullable. This means that if the value being checked is null,
the validation is considered valid.
final
- isOptional → bool
-
Marks the validator as optional. This means that if the value being checked is null or missing,
the validation is considered valid.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{bool? nullable, bool? optional}) → IValidator - Creates a copy of the validator with the given parameters.
-
isNotValid(
dynamic value) → bool - Checks if the given value is not valid.
-
isValid(
dynamic value) → bool - Checks if the given value is valid.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable<
T> () → IValidator - Creates a nullable copy of the validator.
-
optional<
T> () → IValidator - Creates a optional copy of the validator.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
dynamic value, {bool exists = true}) → Result - Main validation method. Use this method if you want to validate that a dynamic value is valid, and get an error message if not.
-
validateAsync(
dynamic value, {bool exists = true}) → Future< Result> - Always returns a Future, allowing async + sync validators to compose.
-
validateOrThrow(
dynamic value) → Result - Works the same as validate, validates that a given value is valid, but throws instead if it's not.
-
validator(
dynamic value) → FutureOr< Result> - Core validation function (may return a Result or Future<Result>). Don't call directly, use validate or validateAsync.
Operators
-
operator &(
IValidator other) → IValidator -
Available on IValidator, provided by the EskemaEskValidatorOperations extension
Combines two validators with a logical AND, same as using all -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator >(
Expectation error) → IValidator -
Available on IValidator, provided by the EskemaEskValidatorOperations extension
Returns a new validator that will return theerror
message if the validation fails -
operator |(
IValidator other) → IValidator -
Available on IValidator, provided by the EskemaEskValidatorOperations extension
Combines two validators with a logical OR, same as using any