Skip to main content

Overview

LocalRegex provides validation for various Zimbabwe identity documents and vehicle registration numbers. These validators ensure that document numbers match the official formats used in Zimbabwe.

National ID Validation

isZimID()

Validates Zimbabwe national ID numbers.
idNumber
String
required
The national ID number to validate
Returns: bool - true if the ID number is valid, false otherwise Pattern: ^(\d{2})(-|\s*)(\d{6,7})(\s)*([A-Za-z])(\s)*(\d{2})$

Format Structure

Zimbabwe national ID numbers follow this format:
1

District Code

2 digits representing the district of registration
2

Separator

A hyphen or space (optional)
3

Registration Number

6-7 digits representing the registration number
4

Check Letter

A single letter (A-Z)
5

Check Digits

2 final digits

Code Examples

LocalRegex.isZimID('63-1234567 A 53');  // true
LocalRegex.isZimID('63-123456 B 12');   // true
LocalRegex.isZimID('631234567A53');     // true (no separators)
LocalRegex.isZimID('63 1234567 C 45');  // true (spaces)
The validator accepts IDs with or without separators (hyphens and spaces). Whitespace is cleaned automatically during validation.

Passport Validation

isZimPassport()

Validates Zimbabwe passport numbers.
passportNumber
String
required
The passport number to validate
Returns: bool - true if the passport number is valid, false otherwise Pattern: ^[A-Z]{2}\d{6}$

Format Structure

Zimbabwe passports consist of:
  • 2 uppercase letters followed by
  • 6 digits

Code Examples

LocalRegex.isZimPassport('AB123456');  // true
LocalRegex.isZimPassport('CD789012');  // true
LocalRegex.isZimPassport('XY999999');  // true
Passport numbers must be in uppercase. The validator expects exactly 2 letters followed by 6 digits.

Driver’s License Validation

isZimDriversLicence()

Validates Zimbabwe driver’s license numbers.
licenseNumber
String
required
The driver’s license number to validate
Returns: bool - true if the license number is valid, false otherwise Pattern: \d{5}[a-zA-Z]{2}

Format Structure

Zimbabwe driver’s licenses consist of:
  • 5 digits followed by
  • 2 letters (uppercase or lowercase)

Code Examples

LocalRegex.isZimDriversLicence('12345AB');  // true
LocalRegex.isZimDriversLicence('98765cd');  // true
LocalRegex.isZimDriversLicence('54321Xy');  // true

Vehicle Number Plate Validation

isZimNumberPlate()

Validates Zimbabwe vehicle registration number plates.
numberPlate
String
required
The number plate to validate
Returns: bool - true if the number plate is valid, false otherwise Pattern: ^[A-Z]{3}(-|\s*)\d{4}$

Format Structure

Zimbabwe number plates consist of:
  • 3 uppercase letters followed by
  • Optional hyphen or space followed by
  • 4 digits

Code Examples

LocalRegex.isZimNumberPlate('ABC-1234');  // true
LocalRegex.isZimNumberPlate('ABC 1234');  // true
LocalRegex.isZimNumberPlate('ABC1234');   // true (no separator)
LocalRegex.isZimNumberPlate('XYZ-9999');  // true
Number plates can be validated with or without separators (hyphens or spaces) between the letters and numbers.

Validation Patterns Summary

National ID

Format: 63-1234567 A 532 digits + 6-7 digits + letter + 2 digits

Passport

Format: AB1234562 uppercase letters + 6 digits

Driver's License

Format: 12345AB5 digits + 2 letters

Number Plate

Format: ABC-12343 uppercase letters + 4 digits

Complete Example

import 'package:localregex/localregex.dart';

void validateDocuments() {
  // Validate National ID
  final nationalId = '63-1234567 A 53';
  if (LocalRegex.isZimID(nationalId)) {
    print('Valid Zimbabwe National ID');
  }
  
  // Validate Passport
  final passport = 'AB123456';
  if (LocalRegex.isZimPassport(passport)) {
    print('Valid Zimbabwe Passport');
  }
  
  // Validate Driver's License
  final license = '12345AB';
  if (LocalRegex.isZimDriversLicence(license)) {
    print('Valid Zimbabwe Driver\'s License');
  }
  
  // Validate Number Plate
  final numberPlate = 'ABC-1234';
  if (LocalRegex.isZimNumberPlate(numberPlate)) {
    print('Valid Zimbabwe Number Plate');
  }
}

Format Flexibility

Most validators accept multiple separator formats:
  • Hyphens: 63-1234567 A 53
  • Spaces: 63 1234567 A 53
  • No separators: 631234567A53
The library automatically cleans whitespace during validation.

Best Practices

Input Sanitization: While the library cleans whitespace automatically, consider normalizing case (uppercase) for passports and number plates before validation.
Not a Security Feature: These validators only check format correctness. They do not verify if a document is genuine or currently valid with authorities.
Example: Pre-processing Input
final userInput = ' ab123456 ';
final normalized = userInput.trim().toUpperCase();

if (LocalRegex.isZimPassport(normalized)) {
  print('Valid passport format');
}

Build docs developers (and LLMs) love