alphabetic static method

String? alphabetic(
  1. String? value, {
  2. String fieldName = 'This field',
})

Validates that the input contains only alphabetic characters.

Implementation

static String? alphabetic(String? value, {String fieldName = 'This field'}) {
  if (value == null || value.isEmpty) return '$fieldName is required';
  if (!RegExp(r'^[a-zA-Z\s]+$').hasMatch(value)) {
    return '$fieldName can only contain letters and spaces';
  }
  return null;
}