alphanumeric static method
Validates that the input contains only alphanumeric characters.
Implementation
static String? alphanumeric(
String? value, {
String fieldName = 'This field',
}) {
if (value == null || value.isEmpty) return '$fieldName is required';
if (!RegExp(r'^[a-zA-Z0-9]+$').hasMatch(value)) {
return '$fieldName can only contain letters and numbers';
}
return null;
}