Validator class
The generic validator class that can be used for various validation purposes
Subclass it accordingly to build your own kind of validation(s). Refer to either ValidatorNumber or ValidatorString for more details.
The common use case is for TextFormField where you can add any of the validators in TextFormField.validator e.g.
TextFormField(
decoration: InputDecoration(labelText: 'Test Less Than 5 and Positive'),
keyboardType: TextInputType.number,
validator: (v) => ValidatorNumber(v).lt(5).positive().build(),
);
- Implementers
Constructors
- Validator(dynamic value)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ dynamic
-
getter/setter pair
Methods
-
build(
) → String? -
length(
{int min = 0, int max = int64Max, String errMsg(String val, int min, int max)?}) → Validator -
Checks the length of the value
makes sure it's between
min
andmax
range -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
optional(
) → Validator -
toString(
) → String -
A string representation of this object.
inherited
-
unless(
ValidationUnless checker) → Validator -
validate(
ValidationRule rule) → Validator
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited