validateZipCode static method

String? validateZipCode(
  1. String? value
)

Implementation

static String? validateZipCode(String? value) {
  if (value == null || value.isEmpty) return "Zip code is required";
  final zipRegex = RegExp(r'^\d{5,6}$');
  return zipRegex.hasMatch(value) ? null : "Enter a valid zip code";
}