validate method

  1. @override
bool validate(
  1. String? value,
  2. Map<String, FormFieldState> fields
)
override

Validates the given value against the validation rule.

  • value: The value to be validated.
  • fields: A map of form field states for cross-field validation.

Returns true if the validation passes, false otherwise.

Implementation

@override
bool validate(String? value, Map<String, FormFieldState> fields) {
  if (value == null) {
    return false;
  }
  return RegExp(r'^[a-zA-Z0-9_-]+$').hasMatch(value);
}