leancode_forms
library
Functions
and <T , E extends Object > (Iterable <Validator <T , E > > validators , [E? sharedMessage ])
→ Validator <T , E >
Each of the given validators has to accept input.
If some accept, first error is returned or sharedMessage
if provided.
atLeastLength <E extends Object > (int minLength , E message )
→ Validator <String ? , E >
Rejects strings shorter than minLength
.
boundedNonNegativeInteger <E extends Object > (int upperBound , E message )
→ Validator <String ? , E >
Of the form >upperBound
or num
where num
is between 0 and upperBound
inclusive
conditionalValidator <T , E extends Object > (Validator <T , E > validator , bool enabledGetter () )
→ Validator <T , E >
If enabledGetter
returns true validator
is ran. Otherwise this accepts all input.
dynamicValidator <T , E extends Object > (Validator <T , E > ? validatorBuilder () )
→ Validator <T , E >
Creates a new validator.
exactly <E extends Object > (String string , E message )
→ Validator <String ? , E >
Requires to be exactly the given string.
filled <E extends Object > (E message )
→ Validator <String ? , E >
Rejects null and empty strings (including whitespace only strings).
nonNegativeDecimal <E extends Object > (E message )
→ Validator <String ? , E >
Checks if the value is a decimal with a value above or equal to 0.
nonNegativeInteger <E extends Object > (E message )
→ Validator <String ? , E >
Checks if the value is a integer with a value above or equal to 0.
notEmpty <T , E extends Object > (E message )
→ Validator <List <T > ? , E >
Rejects null and empty lists
nothing <E extends Object > (E message )
→ Validator <String ? , E >
Matches empty strings
notLongerThan <E extends Object > (int maxLength , E message )
→ Validator <String ? , E >
Rejects strings longer than maxLength
.
notNull <T , E extends Object > (E message )
→ Validator <T? , E >
Rejects null
or <T , E extends Object > (Iterable <Validator <T , E > > validators , [E? sharedMessage ])
→ Validator <T , E >
Only one of the given validators has to accept input.
If none accept, first error is returned or sharedMessage
if provided.
positiveDecimal <E extends Object > (E message )
→ Validator <String ? , E >
Checks if the value is a decimal with a value above 0.
positiveInteger <E extends Object > (E message )
→ Validator <String ? , E >
Checks if the value is a integer with a value above 0.
Typedefs
AsyncValidator <T , E extends Object >
= Future <E? > Function(T )
An async validate function receiving the current value and returning an error code.
ErrorTranslator <E extends Object >
= String Function(E )
Translates an error to a string.
Validator <T , E extends Object >
= E? Function(T )
A validate function receiving the current value and returning an error code.
If null is returned, the value is considered valid.