Identity & Gov Validators

Identity validators for passport numbers, SSN, Aadhaar, PAN, and government ID verification.

28 code snippets available

SSN (US)

identity

Social Security Number.

#identity#us#gov
ts
const isValid = (s: string): boolean => /^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/.test(s);

EIN (US)

identity

Employer Identification Number.

#identity#tax#us
ts
const isValid = (s: string): boolean => /^[1-9]\d?-\d{7}$/.test(s);

Passport (Generic)

identity

6-9 alphanumeric characters.

#identity#travel
ts
const isValid = (s: string): boolean => /^[A-Z0-9]{6,9}$/.test(s);

License Plate (US)

identity

Generic 1-7 alphanum.

#identity#vehicle
ts
const isValid = (s: string): boolean => /^[A-Z0-9]{1,7}$/.test(s);

Aadhar Card (India)

identity

12-digit UIDAI number.

#identity#india#gov
ts
const isValid = (s: string): boolean => /^[2-9]\d{11}$/.test(s);

PAN Card (India)

identity

Permanent Account Number.

#identity#india#tax
ts
const isValid = (s: string): boolean => /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/.test(s);

Driving License (India)

identity

Standard 15-char format.

#identity#india#vehicle
ts
const isValid = (s: string): boolean => /^[A-Z]{2}[0-9]{13}$/.test(s);

Voter ID (India)

identity

EPIC Number.

#identity#india#voting
ts
const isValid = (s: string): boolean => /^[A-Z]{3}[0-9]{7}$/.test(s);

GSTIN (India)

identity

Goods & Services Tax ID.

#identity#india#tax
ts
const isValid = (s: string): boolean => /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/.test(s);

National Insurance (UK)

identity

UK NI Number.

#identity#uk#tax
ts
const isValid = (s: string): boolean => /^(?!BG|GB|NK|KN|TN|NT|ZZ)[A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}[0-9]{6}[A-D]{1}$/.test(s);

NHS Number (UK)

identity

10 digit NHS identifier.

#identity#uk#health
ts
const isValid = (s: string): boolean => /^\d{10}$/.test(s);

Driving License (UK)

identity

UK License Number.

#identity#uk#vehicle
ts
const isValid = (s: string): boolean => /^[A-Z9]{5}\d{6}[A-Z9]{2}\d{3}$/.test(s);

CPF (Brazil)

identity

Brazilian Tax ID.

#identity#brazil#tax
ts
const isValid = (s: string): boolean => /^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(s);

CNPJ (Brazil)

identity

Brazilian Business Tax ID.

#identity#brazil#business
ts
const isValid = (s: string): boolean => /^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/.test(s);

Resident ID (China)

identity

18-digit Resident ID.

#identity#china#gov
ts
const isValid = (s: string): boolean => /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(s);

VIN Number

identity

Vehicle Identification Number.

#vehicle#vin
ts
const isValid = (s: string): boolean => /^[A-HJ-NPR-Z0-9]{17}$/.test(s);

IMEI

identity

15-digit device identifier.

#device#mobile
ts
const isValid = (s: string): boolean => /^\d{15}$/.test(s);

ICCID

identity

SIM card identifier.

#sim#mobile
ts
const isValid = (s: string): boolean => /^\d{18,22}$/.test(s);

DUNS Number

identity

9-digit business ID.

#business#duns
ts
const isValid = (s: string): boolean => /^\d{9}$/.test(s);

LEI Code

identity

Legal Entity Identifier.

#legal#entity
ts
const isValid = (s: string): boolean => /^[A-Z0-9]{18}[0-9]{2}$/.test(s);

NPI (US)

identity

National Provider Identifier.

#healthcare#us
ts
const isValid = (s: string): boolean => /^\d{10}$/.test(s);

DEA Number

identity

Drug Enforcement Admin number.

#healthcare#us
ts
const isValid = (s: string): boolean => /^[A-Z][A-Z9][0-9]{7}$/.test(s);

Student ID

identity

Standard student ID format.

#education#student
ts
const isValid = (s: string): boolean => /^[A-Z]{2,4}\d{6,10}$/.test(s);

Serial Number

identity

Hardware serial number.

#hardware#serial
ts
const isValid = (s: string): boolean => /^[A-Z0-9]{8,20}$/.test(s);

Hardware UUID

identity

Device UUID format.

#hardware#device
ts
const isValid = (s: string): boolean => /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/.test(s);

Raspberry Pi Serial

identity

Pi serial number.

#hardware#raspberrypi
ts
const isValid = (s: string): boolean => /^[0-9a-f]{16}$/.test(s);

ORCID

identity

Researcher identifier.

#science#researcher
ts
const isValid = (s: string): boolean => /^\d{4}-\d{4}-\d{4}-\d{3}[0-9X]$/.test(s);

Bar Number

identity

Attorney bar ID.

#legal#attorney
ts
const isValid = (s: string): boolean => /^[A-Z]{2}\d{5,7}$/.test(s);

About Identity & Gov Validators

Our identity & gov validation snippets are designed to handle the most common validation scenarios you'll encounter in modern software development. Each snippet is thoroughly tested, optimized for performance, and follows industry best practices.

All validators are available in multiple programming languages including JavaScript, TypeScript, Python, Go, PHP, C#, and Rust. Simply copy the code snippet, adapt it to your specific needs, and integrate it into your project. Every snippet is MIT licensed—free for personal and commercial use.

Browse Other Categories