DocsValidators

npi validator

US National Provider Identifier — 10 digits, Luhn check on `80840` prefix.

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

Implementation

Faithful summary of lib/validators.ts. Validators are pure functions and run identically in the worker, the Workbench, and the MCP server.

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')
}

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: npi

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.

Related templates

  • Provider directoryprovider_directory_v1

    Providers with NPI/GLN/license metadata.

    Fields: npi

Pricing

Validators run on every committed row

Schema-only mode (headers + ≤3 sample rows) is free and unlimited; full-data commits are metered. See plans →