FormValidator constructor

FormValidator({
  1. required Map<String, List<ValidatorEvent>> fields,
  2. required String name,
  3. WebRequest? rq,
  4. Object failed = 'is-invalid',
  5. Object success = '',
  6. Map<String, Object?> extraData = const {},
})

Constructor to initialize the FormValidator.

Parameters:

  • rq: The web request object containing form data. (required)
  • fields: A map of fields to validate with their respective validation rules. (required)
  • name: The name of the form or validation context. (required)
  • failed: The value to mark a field as invalid. (optional, defaults to 'is-invalid')
  • success: The value to mark a field as valid. (optional, defaults to an empty string)
  • extraData: Additional data to be considered during validation. (optional, defaults to an empty map)

Implementation

FormValidator({
  required this.fields,
  required this.name,
  this.rq,
  this.failed = 'is-invalid',
  this.success = '',
  this.extraData = const {},
}) {
  if (rq == null && extraData.isEmpty) {
    throw ArgumentError(
      'WebRequest or extraData is required for FormValidator',
    );
  }
}