postalCode method

  1. @override
String? postalCode(
  1. String? value
)
override

Validates the postal code for a specific country.

Implementation

@override
String? postalCode(String? value) {
  if (value == null || value.trim().isEmpty) {
    return 'Postal code is required';
  }

  if (!_plzRegex.hasMatch(value.trim())) {
    return 'Invalid German postal code';
  }

  return null;
}