National id validate
national-id-validate · version 1.0.0 · Identifiers & check digits · free, no key needed
Validate a personal identity number’s format and, where defined, checksum for one of 14 national schemes.
Use when you need to: validate a national id number · check an israeli teudat zehut check digit · validate an aadhaar number.
Decide before calling
Read the versioned contract and the supported scope below. Reuse national-id-validate@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use national-id-validate@1.0.0 for validate a national id number. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- validate a national id number
- check an israeli teudat zehut check digit
- validate an aadhaar number
- check a spanish dni or nie letter
- validate a dutch bsn with the 11-proof
- check digit for a french nir social security number
- is this a real polish pesel number
- בדיקת תעודת זהות ישראלית
Not supported
- a registry or government lookup to confirm the identity actually exists
- a national ID scheme not in the 14-value enum (no generic/unknown-country mode)
- computing or issuing a new identity number
Behavior
- value must be a non-empty string of at most 15 UTF-8 bytes (limit_exceeded if longer, checked before anything else); scheme must be one of the 14 enum values. Every other problem is reported as {valid:false, reason} rather than thrown, per family convention for validate-style tools.
- Reason precedence per scheme, stopping at the first that applies: (1) wrong_length, (2) invalid_character, (3) invalid_component (a structural sub-field such as date, sex digit, century sign or citizenship digit out of range), (4) checksum_mismatch (only for schemes whose checksum is 'verified').
- il-tz: 1-9 digits, left-padded with 0 to 9, standard Luhn; an all-zero normalized value is invalid_component (never issued). in-aadhaar: exactly 12 digits not starting with 0 or 1, Verhoeff. es-dni/es-nie: 9 characters, mod-23 letter table (TRWAGMYFPDXBNJZSQVHLCKE) over 8 digits (NIE’s X/Y/Z leading letter maps to 0/1/2).
- uk-nino: 9 characters (2 letters, 6 digits, 1 of A/B/C/D), format only, with HMRC’s excluded prefix letters/combinations enforced as invalid_component. nl-bsn: 9 digits, the elfproef (11-proof) weighted sum must be a true multiple of 11; an all-zero value is invalid_component (never issued, even though it satisfies the arithmetic).
- za-id: 13 digits YYMMDD+SSSS+C+A+Z, month/day validated under a leap-permissive rule (century unresolvable from 2 digits), citizenship digit 0 or 1, standard Luhn over all 13 digits.
- fr-nir: 15 characters, sex 1/2, month 01-12 or 20, département 01-95, 97 (overseas), 98 (overseas) or 99 (born abroad), or the Corsican codes 2A/2B (substituted 19/18 for the key computation); key = 97 - (13-digit body mod 97) (or 97 when that remainder is 0). be-nn: 11 digits, key = 97 - (9-digit body mod 97), tried both with and without a leading ‘2’ prefix (pre-/post-2000 birth year), either match is accepted.
- fi-hetu: 11 characters DDMMYY+sign+NNN+check, sign one of + - A-F U-Y fixing the century (+ 1800s, - and U-Y 1900s, A-F 2000s); DDMMYY must be a real proleptic Gregorian date in that resolved year (29 February only in a real leap year), mod-31 check character over DDMMYY+NNN (alphabet 0-9A-HJ-NP-TUVWXY, omitting look-alikes). no-fnr: 11 digits, double MOD 11 (weights [3,7,6,1,8,9,4,5,2] then [5,4,3,2,7,6,5,4,3,2] over the body plus the first check digit); a remainder of 1 in either pass has no valid check digit and fails outright; D-numbers (day+40), H-numbers (month+40) and synthetic numbers (month+80) fail the same day/month range check as an ordinary fødselsnummer and are reported invalid_component (this tool does not decode or accept them separately).
- pl-pesel: 11 digits, month carries a century offset (0/20/40/60/80 for 1900s/2000s/2100s/2200s/1800s) that also resolves the full birth year; the day must be a real day of that real year (29 February only in a real leap year), weighted mod-10 check digit (weights [1,3,7,9,1,3,7,9,1,3]). us-ssn: 9 digits, format-only component ranges (no checksum). ca-sin: 9 digits, first digit not 0 or 8, standard Luhn.
- Pure integer and table-lookup arithmetic; no locale, clock, or randomness; identical output across runs for the same input.
Input
value(string, required): min length 1; max length 15scheme(one of "il-tz", "in-aadhaar", "es-dni", "es-nie", "uk-nino", "nl-bsn", "za-id", "fr-nir", "be-nn", "fi-hetu", "no-fnr", "pl-pesel", "us-ssn", "ca-sin", required)
Output
valid(boolean, required)reason(one of null, "wrong_length", "invalid_character", "invalid_component", "checksum_mismatch", required)scheme(one of "il-tz", "in-aadhaar", "es-dni", "es-nie", "uk-nino", "nl-bsn", "za-id", "fr-nir", "be-nn", "fi-hetu", "no-fnr", "pl-pesel", "us-ssn", "ca-sin", required)normalized(string, required): min length 1; max length 15checksum(one of "verified", "not_defined", required)
Limits
- max value bytes: 15
Example
Request input:
{
"value": "12345678Z",
"scheme": "es-dni"
}
Response:
{
"result": {
"valid": true,
"reason": null,
"scheme": "es-dni",
"normalized": "12345678Z",
"checksum": "verified"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "national-id-validate",
"version": "1.0.0",
"input": {
"value": "12345678Z",
"scheme": "es-dni"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/national-id-validate/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"12345678Z","scheme":"es-dni"}'
The machine-readable contract is at /v1/tools/national-id-validate/versions/1.0.0.
CLI
node cli.mjs run national-id-validate 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Tax id validate: Validate a taxpayer/business registration number’s format and, where defined, checksum for one of 12 national schemes.
- Eu vat id validate: Detect the country from an EU/XI VAT id prefix and validate its format and, where defined, national checksum.
- Npi validate: Validate a 10-digit US National Provider Identifier using the Luhn formula with the constant 80840 healthcare prefix.
- Imo number validate: Validate a 7-digit IMO ship identification number's weighted mod-10 check digit, with or without the 'IMO ' prefix.
- Isin validate: Validate a 12-character ISIN's ISO 6166 Luhn check digit and parse its country prefix, NSIN and NSIN scheme.
- Uk nhs number validate: Validate a 10-digit NHS number's modulus 11 check digit (NHS Data Dictionary); 11 minus remainder = 10 is never valid.