validate method

  1. @override
bool validate(
  1. dynamic value, [
  2. List<String>? options
])
override

Validates if the given value is a valid word.

This method checks if the value is not null and matches the regular expression for a word, which includes alphanumeric characters and underscores.

  • value: The value to be validated.
  • options: An optional list of additional options for validation.

Returns true if the value is a valid word, otherwise false.

Implementation

@override
bool validate(dynamic value, [List<String>? options]) {
  if (value == null) return false;
  return RegExp(r'^\w+$').hasMatch(value.toString());
}