ID Number Regex Examples

Validate the ID number format to prevent failed ID lookups

The most common reason for failure of an ID lookup is because the end user did not input their ID number correctly. One of the best ways to mitigate this is to validate ID numbers on the client, before sending them to Smile Identity. Below we will provide validation regexes for most of our ID types. It is important to note that they change over time, and we will do our best to keep this page updated.

These examples were developed for use in Java and JavaScript. Different languages have slightly different implementations of regex rules, so some customization may be required.

Java Regex examples

GHANA_SSNIT_REGEX = /^[a-zA-Z]{1}[a-zA-Z0-9]{12,14}$/
GHANA_VOTER_ID_REGEX = /^[0-9]{10,12}$/
GHANA_PASSPORT_REGEX = /^(?i)G[a-zA-Z0-9]{7,9}$/
GHANA_NATIONAL_ID_REGEX = /^(?i)GHA-[a-zA-Z0-9]{9}-[a-zA-Z0-9]{1}$/
KENYA_NATIONAL_ID_REGEX = /^[0-9]{1,9}$/
KENYA_PASSPORT_REGEX = /^[A-Z0-9]{7,9}$/
KENYA_ALIEN_CARD_REGEX = /^[0-9]{6,9}$/
NIGERIA_BVN_REGEX = /^[0-9]{11}$/
NIGERIA_NIN_REGEX = /^[0-9]{11}$/
NIGERIA_NIN_SLIP_REGEX = /^[0-9]{11}$/
NIGERIA_DRIVER_LICENSE_REGEX = /^[a-zA-Z]{3}([ -]{1})?[A-Z0-9]{6,12}$/
NIGERIA_VOTER_ID_REGEX = /^[a-zA-Z0-9 ]{9,19}$/
NIGERIA_CAC_REGEX = /^(RC)?[0-9]{5,8}$/
NIGERIA_TIN_REGEX = /^[0-9]{8,}-[0-9]{4,}$/

JavaScript Regex Examples

let regexes = {
GH: {
DRIVERS_LICENSE: /^[A-Z0-9]{6,10}$/i,
SSNIT: /^[A-Z]{1}[A-Z0-9]{12,14}$/i,
VOTER_ID: /^[0-9]{10,12}$/,
PASSPORT: /^G[A-Z0-9]{7,9}$/i,
NATIONAL_ID: /^GHA-[A-Z0-9]{9}-[A-Z0-9]{1}$/i
KE: {
NATIONAL_ID: /^[0-9]{1,9}$/,
PASSPORT: /^[A-Z0-9]{7,9}$/,
ALIEN_CARD: /^[0-9]{6,9}$/
NG: {
BVN: /^[0-9]{11}$/,
NIN: /^[0-9]{11}$/,
NIN_SLIP: /^[0-9]{11}$/,
DRIVERS_LICENSE: /^(?=.*[0-9])(?=.*[A-Z])[A-Z0-9]{3}([ -]{1})?[A-Z0-9]{6,12}$/i,
VOTER_ID: /^([A-Z0-9]{19}|[A-Z0-9]{9})$/i,
CAC: /^(RC)?[0-9]{5,8}$/,
TIN: /^[0-9]{8,}-[0-9]{4,}$/
ZA: {
NATIONAL_ID: /^[0-9]{13}$/