eskema library

Classes

Result
Basic implementation of IResult

Mixins

IResult
Represents the result of a validation

Functions

all(List<Validator> validators) Validator
Valid if every validator is valid or returns the first invalid result
and(Validator validator1, Validator validator2) Validator
Passes the test if both of the Validators are valid, and fails if any of them are invalid
eskema(Map<String, Validator> eskema) Validator
Returns a Validator that checks a value against a Map eskema that declares a validator for each key.
eskemaList(List<Validator> eskema) Validator
Returns a Validator that checks a value against the eskema provided, the eskema defines a validator for each item in the list
isDate() Validator
Checks whether the given value is a valid DateTime formattedString
isDeepEq<T>(T expected) Validator
Checks whether the given value is equal to the expected value of type T
isEq<T>(T expected) Validator
Checks whether the given value is equal to the expected value of type T
isGt(num min) Validator
Checks whether the given value is greater than max
isGte(num min) Validator
Checks whether the given value is greater or equal to max
isLt(num max) Validator
Checks whether the given value is less than max
isLte(num max) Validator
Checks whether the given value is less than or equal max
isType<T>() Validator
Returns a Validator that checks if the given value is the correct type
isTypeNull() Validator
Returns a Validator that checks if the given value null
isTypeOrNull<T>() Validator
Returns a Validator that checks if the given value is the correct type
listContains<T>(T item) Validator
Validates that the List contains item
listEach(Validator itemValidator) Validator
Returns a Validator that runs itemValidator for each item in the list
listIsOfLength(int size) Validator
Validates that the list's length is the same as the provided size
not(Validator validator) Validator
Passes the test if the contition is !valid
nullable(Validator validator) Validator
Allows the passed in validator to be nullable
or(Validator validator1, Validator validator2) Validator
Passes the test if either of the Validators are valid, and fails if both are invalid
stringContains(String substring) Validator
Validates that the String contains substring
stringIsOfLength(int size) Validator
Validates that the String's length is the same as the provided size
stringMatchesPattern(Pattern pattern, {String? expectedMessage}) Validator
Validates that the String matches the provided pattern
stringNotContains(String substring) Validator
Validates that the String does not contain substring
throwInstead(Validator validator) Validator
Returns a Validator that throws a ValidatorFailedException instead of returning a result

Typedefs

Validator = IResult Function(dynamic value)