validateMobile static method

String? validateMobile(
  1. String? value
)

Validates a 10-digit mobile number. Returns null if valid, otherwise an error message.

Implementation

static String? validateMobile(String? value) {
  if (value == null || value.isEmpty) return 'Mobile number is required';
  final mobileRegex = RegExp(r'^\d{10}$');
  if (!mobileRegex.hasMatch(value)) return 'Enter a valid 10-digit mobile number';
  return null;
}