validateHealthInsurancePolicyNumber function

String? validateHealthInsurancePolicyNumber(
  1. String? value
)

Validates a Health Insurance Policy Number. Returns null if valid, or an error message string if invalid.

Implementation

String? validateHealthInsurancePolicyNumber(String? value) {
  if (value == null || value.isEmpty) {
    return 'Please enter a health insurance policy number';
  }
  // Basic alphanumeric check, can be adjusted for format specifics.
  if (!RegExp(r'^[A-Z0-9-]+$').hasMatch(value)) {
    return 'Enter a valid health insurance policy number';
  }
  return null;
}