FormValidator class
A class for validating form data using customizable field validators.
The FormValidator
class allows defining validation rules for form fields
and then validating input data against those rules. It also handles error
reporting and formatting for easy form validation and feedback display.
Constructors
-
FormValidator({required WebRequest rq, required Map<
String, List< fields, required String name, Object failed = 'is-invalid', Object success = '', Map<ValidatorEvent> >String, Object> extraData = const {}}) -
Constructor to initialize the
FormValidator
.
Properties
-
extraData
↔ Map<
String, Object> -
Additional data that can be used in validation, not coming directly from the request.
getter/setter pair
- failed ↔ Object
-
The value to indicate a field is invalid.
getter/setter pair
-
fields
↔ Map<
String, List< ValidatorEvent> > -
A map of field names to a list of validator events that will be applied to them.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- name ↔ String
-
The name of the form or validation context. we will use this name in front-end and api key.
getter/setter pair
- rq ↔ WebRequest
-
The web request instance containing the form data to validate.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- success ↔ Object
-
The value to indicate a field is valid.
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
{Map data = const {}}) → Future< bool> - Validates the form data and returns a boolean result.
-
validateAndForm(
{Map data = const {}}) → Future< ({Map< String, dynamic> form, bool result})> - Validates the form data and returns both the result and the validated form structure.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
filling(
{required WebRequest rq, required String name, required Map data}) → Future< FormValidator> -
Creates and returns a
FormValidator
instance with empty validators for all fields indata
.