validator property

String? Function(String? value)? get validator

A function that validates the input value.

By default, this returns null, indicating that there is no validation.

Example:

@override
String? Function(String? value)? get validator => (value) {
  if (value == null || value.isEmpty) {
    return 'This field cannot be empty';
  }
  if (value.length < 3) {
    return 'Must be at least 3 characters long';
  }
  return null; // Valid input
};

This validator function can be customized to perform various checks (e.g., non-empty validation, length checks, pattern matching, etc.).

Implementation

String? Function(String? value)? get validator => null;