nameValidator top-level property

String? Function(String?)? nameValidator
getter/setter pair

Validates a name input field.

Returns an error message if the input is empty or null.

Returns null if the input is valid.

Implementation

String? Function(String?)? nameValidator = (String? value) {
  if (value == null || value.isEmpty) {
    return 'Please Enter Name';
  }
  if (value.length < 2) return 'Name must be at least 2 characters long';

  return null;
};