validateName method

String? validateName(
  1. String input
)

Implementation

String? validateName(String input) {
  const pattern = r'(^[a-zA-Z]{1,35}$)';
  final regExp = RegExp(pattern);

  if (input.isEmpty) {
    return 'Entry Required';
  } else if (input.length > 35) {
    return 'Maximum of 35 characters';
  } else if (!regExp.hasMatch(input)) {
    return 'Only alpha characters accepted';
  } else {
    return null;
  }
}