Validator class
Container class for a series of ValueValidator objects. Each ValueValidator will be evaluated in a short-circuited way such that as soon as one returns an error evaluation will immediately be stopped and the error will be returned.
This has a set of built-in validators that it can decode and supports applications adding their own custom validator builders.
See also:
Constructors
-
Validator({required List<
ValueValidator> validators})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
validators
→ List<
ValueValidator> -
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Encodes this class into a JSON-compatible Map.
-
toString(
) → String -
Returns the string encoded JSON representation for this class. This will
remove all null values and empty collections from the returned string.
inherited
-
validate(
{required String label, required String? value}) → String? - Executes each of the validators, in order. This will fail-fast where it will stop walking the list as soon as any validator returns an error.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromDynamic(
dynamic map) → Validator -
Processes the list of ValueValidator objects from the given
map
which must be an actual Map or a Map-like object that supports the[]
operator. Any object that is not Map-like will result in an error. -
registerCustomValidatorBuilder(
String type, JsonClassBuilder< ValueValidator> builder) → void -
Registers a custom validator
builder
for the giventype
. This will replace / overwrite any builder already registered for the giventype
. -
unregisterCustomValidatorBuilder(
String type) → void -
Unregisters / removes a custom builder from the given
type
. This will do nothing if thetype
is not already registered.