PiiCatalog.Validators.NationalIds (pii_catalog v0.1.0)

Copy Markdown View Source

National identity, tax and social security numbers: the checks for :pesel_pl, :rrn_be, :ppsn_ie, :nif_pt, :ahv_ch, :svnr_at, :isikukood_ee and :nhs_gb.

Each is written from what its issuer, or the issuer's government, publishes, except the isikukood's check digit:

  • :pesel_pl – Ustawa o ewidencji ludności, art. 15, and the Rozporządzenie MSW z dnia 4 stycznia 2012 r. w sprawie nadania lub zmiany numeru PESEL, § 7.
  • :rrn_be – Registre national, "T.I. 000 – Le numéro d'identification" (2016), and the Banque Carrefour de la sécurité sociale, "Registres: concepts et règles".
  • :ppsn_ie – Department of Social Protection, "Extension of the Personal Public Service Number Range", for the structure and the ninth character. It does not give the weights or the letter for each remainder. Those are taken from the Irish VAT number rules Ireland published through the Austrian Ministry of Finance (see PiiCatalog.Validators.VatEu), and they reproduce both of the department's examples.
  • :nif_pt – Decreto-Lei n.º 14/2013, art. 4 (nine digits, the last a check digit), and the Portuguese VAT rules published through the Austrian Ministry of Finance, whose number is the NIF.
  • :ahv_ch – the Central Compensation Office (ZAS), "AHV-Nummer", and the Federal Social Insurance Office's Wegleitung über Versicherungsausweis und individuelles Konto, annex 7.
  • :svnr_at – Anfragebeantwortung 4690/AB XXIII. GP (Federal Ministry of Health, 2008), and the Dachverband der Sozialversicherungsträger's description of the number.
  • :isikukood_ee – Siseministri määrus "Isikukoodide moodustamise ja andmise kord", § 4, for the structure. The check digit is defined in the standard EVS 585, which is sold, not published. The rule checked is the one the Estonian Wikipedia article "Isikukood" gives, which the Information System Authority's eID overview cites on the formula's origin and its weakness.
  • :nhs_gb – the NHS Data Dictionary, "NHS NUMBER".

Two checks also compare the date of birth with today's date (Date.utc_today/0): :pesel_pl and :isikukood_ee refuse a date after today. :rrn_be tries the reading for people born from 2000 only for a year that has begun.

SOURCES.md in the repository gives each source's address.

Summary

Functions

Runs the check for one of the identifiers above on a matched value. Separators the pattern allows are dropped first.

Functions

valid?(atom, value)

@spec valid?(
  :pesel_pl
  | :rrn_be
  | :ppsn_ie
  | :nif_pt
  | :ahv_ch
  | :svnr_at
  | :isikukood_ee
  | :nhs_gb,
  binary()
) :: boolean()

Runs the check for one of the identifiers above on a matched value. Separators the pattern allows are dropped first.

iex> PiiCatalog.Validators.NationalIds.valid?(:nhs_gb, "943 476 5919")
true
iex> PiiCatalog.Validators.NationalIds.valid?(:nhs_gb, "943 476 5918")
false