Validator class
Enforces the validity of input data, according to Matchers.
Constructors
Properties
-
customErrorMessages
→ Map<
String, dynamic> -
Pre-defined error messages for certain fields.
final
-
defaultValues
→ Map<
String, dynamic> -
Values that will be filled for fields if they are not present.
final
-
errorMessages
→ List<
String> -
Validation error messages.
final
-
forbiddenFields
→ List<
String> -
Fields that cannot be present in valid data.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
requiredFields
→ List<
String> -
Fields that must be present for data to be considered valid.
final
-
rules
→ Map<
String, List< Matcher> > -
Conditions that must be met for input data to be considered valid.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addRule(
String key, Matcher rule) → void -
Adds a
rule
. -
addRules(
String key, Iterable< Matcher> rules) → void -
Adds all given
rules
. -
check(
Map inputData) → ValidationResult - Validates, and filters input data.
-
checkParsed(
Map inputData, List< String> fields) → ValidationResult - Validates, and filters input data after running autoParse.
-
customError(
String key, dynamic value) → String - Renders the given custom error.
-
describe(
Description description) → Description -
Builds a textual description of the matcher.
override
-
describeMismatch(
dynamic item, Description mismatchDescription, Map matchState, bool verbose) → Description -
Builds a textual description of a specific mismatch.
inherited
-
enforce(
Map inputData, {String errorMessage = 'Invalid data.'}) → Map< String, dynamic> - Validates input data, and throws an error if it is invalid.
-
enforceParsed(
Map inputData, List< String> fields) → Map<String, dynamic> - Validates, and filters input data after running autoParse, and throws an error if it is invalid.
-
extend(
Map< String, dynamic> schema, {Map<String, dynamic> defaultValues = const {}, Map<String, dynamic> customErrorMessages = const {}, bool overwrite = false}) → Validator - Creates a copy with additional validation rules.
-
matches(
dynamic item, Map matchState) → bool -
Does the matching of the actual vs expected values.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeRule(
String key, Matcher rule) → void -
Removes a
rule
. -
removeRules(
String key, Iterable< Matcher> rules) → void -
Removes all given
rules
. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited