Docs · Validators
npi validator
US National Provider Identifier — 10 digits, Luhn check on `80840` prefix.
Reference
Format
Matches `/^\d{10}$/`, then runs the CMS-specified Luhn check: compute Luhn on `"80840" + value.slice(0, 9)`, then the trailing digit of `value` must be the Luhn check digit.
Examples
- 1234567893
- 1003000126
- 1467560003
How it runs
Implementation
A faithful summary of lib/validators.ts. Validators are pure functions and run identically in the Worker, the Workbench and the MCP server — one implementation, so the three cannot disagree about whether a value is valid.
function validNpi(value) {
if (!/^\d{10}$/.test(value)) return fail('npi_format', 'expected 10 digits')
const target = ('80840' + value.slice(0, 9)).split('').map(Number)
let sum = 0
for (let i = target.length - 1; i >= 0; i--) {
let d = target[i]
if ((target.length - i) % 2 === 1) { d *= 2; if (d > 9) d -= 9 }
sum += d
}
return (sum + Number(value[9])) % 10 === 0
? OK
: fail('npi_checksum', 'NPI Luhn check failed')
}Config
Use in a template
Validators attach to a field on a custom template. The cascade runs them after mapping but before commit; failures surface in the per-row validation report.
fields:
- column: npi
type: string
validators:
- type: npiWatch out
Common gotchas
- The `80840` prefix is per CMS NPI specification — do NOT pass an 80840-prefixed string in; pass the bare 10-digit NPI.
- Type 1 (individual) and Type 2 (organisation) NPIs use the same checksum — we do not infer or check the entity type.
- NPPES registry lookup is not performed. A syntactically valid NPI may be deactivated.
Where it runs
Three routes, no AI cost.
- POST
/v1/validate-rowValidate one row against a template. Stateless, no key, pure compute — the fastest way to try npi against a real value.no key - POST
/v1/uploads/:id/validateRun every field validator over the parsed upload, without committing. Returns errors and warnings per row.read - POST
/v1/uploads/:id/commitValidates on the way out.skip_invalid_rowsdrops the failures instead of failing the commit.commit
Validators are pure functions, so they add nothing to the AI bill. Every map draws a small flat per-map fee from your prepaid token wallet ($10 minimum, shared across the phi-cloud suite); only columns that reach the metered LLM layer, plus any-to-any convert and structural reshape, bill real AI tokens. See pricing
Catalogue
Related templates
- Provider directory
provider_directory_v1Providers with NPI/GLN/license metadata.
Fields ·
npi
Explore
All 19 validator types
The complete list a template field can declare. There is no SNOMED validator — it required an affiliate licence, no template used it, and it was removed in 2026.
- npi
- regex
- enum
- date_range
- number_range
- phone
- url
- iban
- bic
- uuid
- gtin
- pharmacode
- fhir_reference
- loinc_code
- icd10_code
- atc_code
- cpt_code
- gln
Back to the documentation index or browse the template catalogue.
Ready when you are
Validate every row — before it lands.
Attach checksum-strict validators to any field, and gate risky commits behind the requires_hitl flag. One key runs the whole cascade.