Validation guidelines
This guide covers:
- SA ID Numbers
- Entity Numbers
- Passport Numbers
Validate SA ID Number Guidelines:
Ensure the ID number is in the Correct Format
• Length: The ID must be exactly 13 digits • Numeric Check: Ensure it contains only numbers (no letters or special characters)
Extract and Validate Birth Date:
YYMMDD SSSS C A Z
• YYMMDD: The first six digits represents the birth date • A sequence number (random, but males have 0000-4999 and females 5000-9999) • C: Citizenship (0 = SA Citizens, 1 = Permanent Resident • Z: A checksum digit (validate using the Luhn Algorithm)
Steps to Validate the Birth Date:
• Extract YYMMDD form the ID • If YY is 00-99, assume 1900s or 2000s
Determine the Century:
• Check if "20YY is less than or equal to the current year • If "20YY" is greater than the current year, assume "19YY" • Use a date function to validate the extracted birth date
Validate the Citizenship Digit:
• 0 = South African Citizen • 1 = Permanent Resident • Anything else = Invalid
Apply the Luhn Algorithm for Checksum Validation:
• Double every Second digit from the right – See Example below: • If the doubled value is greater than 9, subtract 9 • Sum all the digits • If the total is a multiple of 10 the ID is valid.
Combine All Checks
• Validate length and numeric format • Validate Birth date • Validate Citizenship • Validate Luhn Checksum
Luhn Algorithm
Identify Digits:
TEST ID (VALID): 7905105190089
Each digit is numbered from left to right:
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 7 | 9 | 0 | 5 | 1 | 0 | 5 | 1 | 9 | 0 | 0 | 8 | 9 |
Double every second digit from the right
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 7 | 9 | 0 | 5 | 1 | 0 | 5 | 1 | 9 | 0 | 0 | 8 | 9 |
| DOUBLE | 18 | 10 | 0 | 2 | 0 | 16 |
If doubled digit is greater than 9 extract 9
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 7 | 9 | 0 | 5 | 1 | 0 | 5 | 1 | 9 | 0 | 0 | 8 | 9 |
| DOUBLE | 18 | 10 | 0 | 2 | 0 | 16 | |||||||
| EXTRACT | 9 | 1 | 0 | 2 | 0 | 7 |
Add up all the digits
Non double digits (Positions 1,3,5,7,9,11,13)
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 7 | 0 | 1 | 5 | 9 | 0 | 9 |
TOTAL 31
Modified Doubled Digits (Positions 2,4,6,8,10,12
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| EXTRACT | 9 | 1 | 0 | 2 | 0 | 7 |
TOTAL:19
SUM the Total of Non double digits and Total of Modified digits
$$ 31+19=50 $$
If the sum is a multiple of 10, the ID number is valid
In this case the total is 50 therefore this is a VALID ID
TEST ID (INVALID): 9202204720085
Each digit is numbered from left to right:
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 9 | 2 | 0 | 2 | 2 | 0 | 4 | 7 | 2 | 0 | 0 | 8 | 5 |
Double every second digit from the right
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 9 | 2 | 0 | 2 | 2 | 0 | 4 | 7 | 2 | 0 | 0 | 8 | 5 |
| DOUBLE | 4 | 4 | 0 | 14 | 0 | 16 |
If doubled digit is greater than 9 extract 9
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 9 | 2 | 0 | 2 | 2 | 0 | 4 | 7 | 2 | 0 | 0 | 8 | 5 |
| DOUBLE | 4 | 4 | 0 | 14 | 0 | 16 | |||||||
| EXTRACT | 4 | 4 | 0 | 5 | 0 | 7 |
Add up all the digits
Non double digits (Positions 1,3,5,7,9,11,13)
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DIGIT | 9 | 0 | 2 | 4 | 2 | 0 | 5 |
TOTAL 22
Modified Doubled Digits (Positions 2,4,6,8,10,12
| LEFT TO RIGHT | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| EXTRACT | 4 | 4 | 0 | 5 | 0 | 7 |
TOTAL:20
SUM the Total of Non double digits and Total of Modified digits
$$ 22+22=42 $$
If the sum is a multiple of 10, the ID number is valid
In this case the total is 42 therefore this is an INVALID ID
Validate SA BUSINESS registration number guidelines:
Business Registration number format:
YYYY/NNNNNN/XX
-
YYYY - Year of Registration
-
NNNNNN = Unique sequential number
-
XX - Business type Identifier
-
Validation steps:
STEPS:
-
Correct format: YYYY/NNNNNN/XX
-
Valid Year (YYYY): must be 4 digits
-
Unique Number: (NNNNNN) Must be a 6 digit number
-
Entity Type (XX):
| Code | Entity Type |
|---|---|
| 07 | Private Company (Pty Ltd) |
| 06 | Public Company (Ltd) |
| 08 | Non-Profit Company (NPC) |
| 23 | Close Corporation (CC) |
| 21 | Incorporated (Professional) |
| 30 | State-Owned Companies |
| 10 | External Companies |
| 26 | Cooperatives |
Note:
-
There is no way to validate the format of the sequence number as an algorithm is not used in this case.
-
The format YYYY/NNNNNN/XX is for pre-account verification validation. Upon submission for Account Verification the / must be removed.
Validate a passport:
Validating a passport number depends on the specific passport issuing country since each country has its own unique format for passport numbers. There isn't a universal validation system for all passport numbers, but some general guidelines can help determine validity or at least confirm proper formatting. Here's how you can approach validating a passport number:
General Guidelines for Passport Number Validation
Length and Format:
• Most passport numbers are between 6 and 9 characters long. • They often consist of a combination of letters (usually one or two) followed by numbers. • Some countries use serial number formats with a combination of letters at the beginning or end.
Country-Specific Formats:
Each country has its own rules for passport number formats:
• United States: A typical U.S. passport number contains 9 characters: a mix of letters and digits. • United Kingdom: Typically contains 9 characters: 1 letter, 7 digits, and 1 letter. • South Africa: South African passports contain 8 characters, usually in the format: A1234567. • Canada: Typically has 9 characters: 1 letter followed by 8 digits. • India: The Indian passport number has 8 characters, beginning with the letter "A" followed by 7 digits.
Check Digits / Luhn Algorithm:
Some countries, especially when using machine-readable passports (MRPs), may include a check digit or apply a checksum algorithm like the Luhn algorithm (common for credit cards and other identification numbers). This checksum ensures that the number is valid based on the structure and mathematical relationship between the digits.
Country Codes and Special Characters:
Certain passport numbers may begin with a country code, indicating the country of issue.
Machine-readable passports (MRPs) include additional information encoded using OCR-B font, typically in the form of MRZ (Machine-Readable Zone) at the bottom.
Steps to Check the Validity of a Passport Number:
• Check the length and structure: Ensure that the passport number follows the expected length and alphanumeric pattern for the issuing country. • Use regular expressions to match the pattern for a specific country's passport format. You can do this by writing a pattern for the expected passport format and checking if the number fits. • Checksum/validation algorithms: For countries that use machine-readable passports, you may need to apply algorithms like Luhn's Algorithm (if applicable) or other country-specific methods to check validity. • Consult the Issuing Authority: To definitively verify the authenticity of a passport, you would need access to the country's passport database or validation systems, which are not publicly accessible for privacy and security reasons.