@stll/stdnum 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/_checksums/luhn.js.map +1 -1
- package/dist/_checksums/mod1110.js +1 -1
- package/dist/_checksums/mod1110.js.map +1 -1
- package/dist/_checksums/mod112.js.map +1 -1
- package/dist/_checksums/mod97.js.map +1 -1
- package/dist/_checksums/verhoeff.js.map +1 -1
- package/dist/_checksums/weighted-sum.js.map +1 -1
- package/dist/_util/arabic.js.map +1 -1
- package/dist/_util/clean.js.map +1 -1
- package/dist/_util/date.js.map +1 -1
- package/dist/_util/generate.js.map +1 -1
- package/dist/_util/result.js.map +1 -1
- package/dist/_util/strings.js.map +1 -1
- package/dist/ad/nrt.d.ts +16 -2
- package/dist/ad/nrt.js +1 -14
- package/dist/ad/nrt.js.map +1 -1
- package/dist/ae/eid.d.ts +2 -2
- package/dist/ae/eid.js +2 -12
- package/dist/ae/eid.js.map +1 -1
- package/dist/ai/tin.d.ts +20 -2
- package/dist/ai/tin.js +1 -18
- package/dist/ai/tin.js.map +1 -1
- package/dist/al/nipt.d.ts +13 -2
- package/dist/al/nipt.js +1 -11
- package/dist/al/nipt.js.map +1 -1
- package/dist/am/tin.d.ts +16 -2
- package/dist/am/tin.js +1 -14
- package/dist/am/tin.js.map +1 -1
- package/dist/ar/cbu.d.ts +2 -2
- package/dist/ar/cbu.js +1 -9
- package/dist/ar/cbu.js.map +1 -1
- package/dist/ar/cuit.d.ts +2 -2
- package/dist/ar/cuit.js +1 -17
- package/dist/ar/cuit.js.map +1 -1
- package/dist/ar/dni.d.ts +11 -2
- package/dist/ar/dni.js +1 -9
- package/dist/ar/dni.js.map +1 -1
- package/dist/at/businessid.d.ts +10 -2
- package/dist/at/businessid.js +1 -8
- package/dist/at/businessid.js.map +1 -1
- package/dist/at/tin.d.ts +2 -2
- package/dist/at/tin.js +1 -11
- package/dist/at/tin.js.map +1 -1
- package/dist/at/uid.d.ts +2 -2
- package/dist/at/uid.js +2 -10
- package/dist/at/uid.js.map +1 -1
- package/dist/at/vnr.d.ts +2 -2
- package/dist/at/vnr.js +4 -14
- package/dist/at/vnr.js.map +1 -1
- package/dist/au/abn.d.ts +2 -2
- package/dist/au/abn.js +1 -10
- package/dist/au/abn.js.map +1 -1
- package/dist/au/acn.d.ts +2 -2
- package/dist/au/acn.js +1 -10
- package/dist/au/acn.js.map +1 -1
- package/dist/au/tfn.d.ts +2 -2
- package/dist/au/tfn.js +1 -10
- package/dist/au/tfn.js.map +1 -1
- package/dist/az/voen.d.ts +2 -2
- package/dist/az/voen.js +1 -14
- package/dist/az/voen.js.map +1 -1
- package/dist/ba/jmbg.d.ts +2 -2
- package/dist/ba/jmbg.js +3 -11
- package/dist/ba/jmbg.js.map +1 -1
- package/dist/bd/nid.d.ts +23 -2
- package/dist/bd/nid.js +1 -21
- package/dist/bd/nid.js.map +1 -1
- package/dist/be/bis.d.ts +2 -2
- package/dist/be/bis.js +1 -11
- package/dist/be/bis.js.map +1 -1
- package/dist/be/nn.d.ts +2 -2
- package/dist/be/nn.js +1 -11
- package/dist/be/nn.js.map +1 -1
- package/dist/be/vat.d.ts +2 -2
- package/dist/be/vat.js +1 -9
- package/dist/be/vat.js.map +1 -1
- package/dist/bg/egn.d.ts +2 -2
- package/dist/bg/egn.js +3 -18
- package/dist/bg/egn.js.map +1 -1
- package/dist/bg/pnf.d.ts +2 -2
- package/dist/bg/pnf.js +1 -8
- package/dist/bg/pnf.js.map +1 -1
- package/dist/bg/vat.d.ts +2 -2
- package/dist/bg/vat.js +3 -9
- package/dist/bg/vat.js.map +1 -1
- package/dist/bh/cpr.d.ts +2 -2
- package/dist/bh/cpr.js +1 -17
- package/dist/bh/cpr.js.map +1 -1
- package/dist/bic.d.ts +13 -2
- package/dist/bic.js +1 -11
- package/dist/bic.js.map +1 -1
- package/dist/br/cnpj.d.ts +2 -2
- package/dist/br/cnpj.js +1 -20
- package/dist/br/cnpj.js.map +1 -1
- package/dist/br/cpf.d.ts +2 -2
- package/dist/br/cpf.js +1 -14
- package/dist/br/cpf.js.map +1 -1
- package/dist/by/unp.d.ts +2 -2
- package/dist/by/unp.js +3 -14
- package/dist/by/unp.js.map +1 -1
- package/dist/bz/tin.d.ts +2 -2
- package/dist/bz/tin.js +1 -26
- package/dist/bz/tin.js.map +1 -1
- package/dist/ca/bn.d.ts +2 -2
- package/dist/ca/bn.js +2 -10
- package/dist/ca/bn.js.map +1 -1
- package/dist/ca/sin.d.ts +2 -2
- package/dist/ca/sin.js +2 -10
- package/dist/ca/sin.js.map +1 -1
- package/dist/ch/ssn.d.ts +2 -2
- package/dist/ch/ssn.js +1 -9
- package/dist/ch/ssn.js.map +1 -1
- package/dist/ch/uid.d.ts +2 -2
- package/dist/ch/uid.js +1 -9
- package/dist/ch/uid.js.map +1 -1
- package/dist/ch/vat.d.ts +2 -2
- package/dist/ch/vat.js +1 -9
- package/dist/ch/vat.js.map +1 -1
- package/dist/cl/rut.d.ts +2 -2
- package/dist/cl/rut.js +1 -14
- package/dist/cl/rut.js.map +1 -1
- package/dist/cn/ric.d.ts +2 -2
- package/dist/cn/ric.js +3 -14
- package/dist/cn/ric.js.map +1 -1
- package/dist/cn/uscc.d.ts +2 -2
- package/dist/cn/uscc.js +1 -10
- package/dist/cn/uscc.js.map +1 -1
- package/dist/co/nit.d.ts +2 -2
- package/dist/co/nit.js +2 -12
- package/dist/co/nit.js.map +1 -1
- package/dist/cr/cpf.d.ts +18 -2
- package/dist/cr/cpf.js +1 -16
- package/dist/cr/cpf.js.map +1 -1
- package/dist/creditcard.d.ts +2 -2
- package/dist/creditcard.js +5 -14
- package/dist/creditcard.js.map +1 -1
- package/dist/cu/ni.d.ts +2 -2
- package/dist/cu/ni.js +2 -17
- package/dist/cu/ni.js.map +1 -1
- package/dist/cy/vat.d.ts +2 -2
- package/dist/cy/vat.js +1 -8
- package/dist/cy/vat.js.map +1 -1
- package/dist/cz/dic.d.ts +2 -2
- package/dist/cz/dic.js +7 -13
- package/dist/cz/dic.js.map +1 -1
- package/dist/cz/ico.d.ts +2 -2
- package/dist/cz/ico.js +2 -10
- package/dist/cz/ico.js.map +1 -1
- package/dist/cz/rc.d.ts +2 -2
- package/dist/cz/rc.js +2 -26
- package/dist/cz/rc.js.map +1 -1
- package/dist/de/handelsreg.d.ts +19 -2
- package/dist/de/handelsreg.js +1 -17
- package/dist/de/handelsreg.js.map +1 -1
- package/dist/de/idnr.d.ts +2 -2
- package/dist/de/idnr.js +2 -12
- package/dist/de/idnr.js.map +1 -1
- package/dist/de/stnr.d.ts +17 -2
- package/dist/de/stnr.js +1 -15
- package/dist/de/stnr.js.map +1 -1
- package/dist/de/svnr.d.ts +2 -2
- package/dist/de/svnr.js +2 -11
- package/dist/de/svnr.js.map +1 -1
- package/dist/de/vat.d.ts +2 -2
- package/dist/de/vat.js +2 -11
- package/dist/de/vat.js.map +1 -1
- package/dist/dk/cpr.d.ts +2 -2
- package/dist/dk/cpr.js +2 -10
- package/dist/dk/cpr.js.map +1 -1
- package/dist/dk/cvr.d.ts +2 -2
- package/dist/dk/cvr.js +2 -15
- package/dist/dk/cvr.js.map +1 -1
- package/dist/dk/vat.d.ts +2 -2
- package/dist/dk/vat.js +3 -13
- package/dist/dk/vat.js.map +1 -1
- package/dist/do/rnc.d.ts +2 -2
- package/dist/do/rnc.js +2 -16
- package/dist/do/rnc.js.map +1 -1
- package/dist/ec/ruc.d.ts +2 -2
- package/dist/ec/ruc.js +1 -18
- package/dist/ec/ruc.js.map +1 -1
- package/dist/ee/ik.d.ts +2 -2
- package/dist/ee/ik.js +3 -20
- package/dist/ee/ik.js.map +1 -1
- package/dist/ee/registrikood.d.ts +2 -2
- package/dist/ee/registrikood.js +1 -8
- package/dist/ee/registrikood.js.map +1 -1
- package/dist/ee/vat.d.ts +2 -2
- package/dist/ee/vat.js +2 -10
- package/dist/ee/vat.js.map +1 -1
- package/dist/eg/tn.d.ts +11 -2
- package/dist/eg/tn.js +1 -9
- package/dist/eg/tn.js.map +1 -1
- package/dist/es/cif.d.ts +2 -2
- package/dist/es/cif.js +1 -10
- package/dist/es/cif.js.map +1 -1
- package/dist/es/dni.d.ts +2 -2
- package/dist/es/dni.js +1 -9
- package/dist/es/dni.js.map +1 -1
- package/dist/es/nie.d.ts +2 -2
- package/dist/es/nie.js +1 -9
- package/dist/es/nie.js.map +1 -1
- package/dist/es/nss.d.ts +2 -2
- package/dist/es/nss.js +1 -16
- package/dist/es/nss.js.map +1 -1
- package/dist/es/vat.d.ts +2 -2
- package/dist/es/vat.js +5 -10
- package/dist/es/vat.js.map +1 -1
- package/dist/eu/vat.d.ts +2 -2
- package/dist/eu/vat.js +1 -0
- package/dist/eu/vat.js.map +1 -1
- package/dist/fi/hetu.d.ts +2 -2
- package/dist/fi/hetu.js +2 -10
- package/dist/fi/hetu.js.map +1 -1
- package/dist/fi/vat.d.ts +2 -2
- package/dist/fi/vat.js +3 -10
- package/dist/fi/vat.js.map +1 -1
- package/dist/fi/ytunnus.d.ts +2 -2
- package/dist/fi/ytunnus.js +2 -10
- package/dist/fi/ytunnus.js.map +1 -1
- package/dist/fr/nif.d.ts +2 -2
- package/dist/fr/nif.js +1 -9
- package/dist/fr/nif.js.map +1 -1
- package/dist/fr/nir.d.ts +2 -2
- package/dist/fr/nir.js +2 -14
- package/dist/fr/nir.js.map +1 -1
- package/dist/fr/siren.d.ts +2 -2
- package/dist/fr/siren.js +2 -10
- package/dist/fr/siren.js.map +1 -1
- package/dist/fr/siret.d.ts +2 -2
- package/dist/fr/siret.js +2 -11
- package/dist/fr/siret.js.map +1 -1
- package/dist/fr/tva.d.ts +2 -2
- package/dist/fr/tva.js +2 -12
- package/dist/fr/tva.js.map +1 -1
- package/dist/gb/nino.d.ts +12 -2
- package/dist/gb/nino.js +1 -10
- package/dist/gb/nino.js.map +1 -1
- package/dist/gb/sedol.d.ts +2 -2
- package/dist/gb/sedol.js +1 -11
- package/dist/gb/sedol.js.map +1 -1
- package/dist/gb/utr.d.ts +2 -2
- package/dist/gb/utr.js +2 -10
- package/dist/gb/utr.js.map +1 -1
- package/dist/gb/vat.d.ts +2 -2
- package/dist/gb/vat.js +2 -11
- package/dist/gb/vat.js.map +1 -1
- package/dist/ge/pin.d.ts +14 -2
- package/dist/ge/pin.js +1 -12
- package/dist/ge/pin.js.map +1 -1
- package/dist/gh/tin.d.ts +2 -2
- package/dist/gh/tin.js +1 -15
- package/dist/gh/tin.js.map +1 -1
- package/dist/gr/amka.d.ts +2 -2
- package/dist/gr/amka.js +3 -11
- package/dist/gr/amka.js.map +1 -1
- package/dist/gr/vat.d.ts +2 -2
- package/dist/gr/vat.js +1 -10
- package/dist/gr/vat.js.map +1 -1
- package/dist/gt/nit.d.ts +2 -2
- package/dist/gt/nit.js +1 -12
- package/dist/gt/nit.js.map +1 -1
- package/dist/hk/hkid.d.ts +2 -2
- package/dist/hk/hkid.js +1 -10
- package/dist/hk/hkid.js.map +1 -1
- package/dist/hr/vat.d.ts +2 -2
- package/dist/hr/vat.js +2 -9
- package/dist/hr/vat.js.map +1 -1
- package/dist/hu/vat.d.ts +2 -2
- package/dist/hu/vat.js +3 -10
- package/dist/hu/vat.js.map +1 -1
- package/dist/iban.d.ts +2 -2
- package/dist/iban.js +2 -8
- package/dist/iban.js.map +1 -1
- package/dist/id/npwp.d.ts +2 -2
- package/dist/id/npwp.js +3 -13
- package/dist/id/npwp.js.map +1 -1
- package/dist/ie/pps.d.ts +2 -2
- package/dist/ie/pps.js +1 -10
- package/dist/ie/pps.js.map +1 -1
- package/dist/ie/vat.d.ts +2 -2
- package/dist/ie/vat.js +1 -9
- package/dist/ie/vat.js.map +1 -1
- package/dist/il/idnr.d.ts +2 -2
- package/dist/il/idnr.js +2 -9
- package/dist/il/idnr.js.map +1 -1
- package/dist/in/aadhaar.d.ts +2 -2
- package/dist/in/aadhaar.js +2 -12
- package/dist/in/aadhaar.js.map +1 -1
- package/dist/in/gstin.d.ts +2 -2
- package/dist/in/gstin.js +1 -10
- package/dist/in/gstin.js.map +1 -1
- package/dist/in/pan.d.ts +15 -2
- package/dist/in/pan.js +1 -13
- package/dist/in/pan.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/iq/nid.d.ts +16 -2
- package/dist/iq/nid.js +2 -15
- package/dist/iq/nid.js.map +1 -1
- package/dist/ir/nid.d.ts +2 -2
- package/dist/ir/nid.js +2 -24
- package/dist/ir/nid.js.map +1 -1
- package/dist/is/kennitala.d.ts +2 -2
- package/dist/is/kennitala.js +2 -13
- package/dist/is/kennitala.js.map +1 -1
- package/dist/is/vsk.d.ts +9 -2
- package/dist/is/vsk.js +1 -7
- package/dist/is/vsk.js.map +1 -1
- package/dist/isin.d.ts +2 -2
- package/dist/isin.js +2 -12
- package/dist/isin.js.map +1 -1
- package/dist/it/codicefiscale.d.ts +2 -2
- package/dist/it/codicefiscale.js +1 -21
- package/dist/it/codicefiscale.js.map +1 -1
- package/dist/it/iva.d.ts +2 -2
- package/dist/it/iva.js +2 -9
- package/dist/it/iva.js.map +1 -1
- package/dist/jp/cn.d.ts +2 -2
- package/dist/jp/cn.js +1 -9
- package/dist/jp/cn.js.map +1 -1
- package/dist/jp/mynumber.d.ts +2 -2
- package/dist/jp/mynumber.js +1 -10
- package/dist/jp/mynumber.js.map +1 -1
- package/dist/kr/brn.d.ts +11 -2
- package/dist/kr/brn.js +1 -9
- package/dist/kr/brn.js.map +1 -1
- package/dist/kr/rrn.d.ts +2 -2
- package/dist/kr/rrn.js +2 -11
- package/dist/kr/rrn.js.map +1 -1
- package/dist/kw/civil.d.ts +2 -2
- package/dist/kw/civil.js +2 -14
- package/dist/kw/civil.js.map +1 -1
- package/dist/kz/iin.d.ts +2 -2
- package/dist/kz/iin.js +3 -18
- package/dist/kz/iin.js.map +1 -1
- package/dist/lei.d.ts +2 -2
- package/dist/lei.js +2 -11
- package/dist/lei.js.map +1 -1
- package/dist/li/peid.d.ts +11 -2
- package/dist/li/peid.js +1 -9
- package/dist/li/peid.js.map +1 -1
- package/dist/lk/nic.d.ts +2 -2
- package/dist/lk/nic.js +2 -14
- package/dist/lk/nic.js.map +1 -1
- package/dist/lt/asmens.d.ts +2 -2
- package/dist/lt/asmens.js +2 -1
- package/dist/lt/asmens.js.map +1 -1
- package/dist/lt/vat.d.ts +2 -2
- package/dist/lt/vat.js +2 -10
- package/dist/lt/vat.js.map +1 -1
- package/dist/lu/vat.d.ts +2 -2
- package/dist/lu/vat.js +2 -8
- package/dist/lu/vat.js.map +1 -1
- package/dist/luhn.d.ts +2 -2
- package/dist/luhn.js +2 -9
- package/dist/luhn.js.map +1 -1
- package/dist/lv/vat.d.ts +2 -2
- package/dist/lv/vat.js +2 -28
- package/dist/lv/vat.js.map +1 -1
- package/dist/ma/ice.d.ts +2 -2
- package/dist/ma/ice.js +2 -11
- package/dist/ma/ice.js.map +1 -1
- package/dist/mc/tva.d.ts +2 -2
- package/dist/mc/tva.js +1 -0
- package/dist/mc/tva.js.map +1 -1
- package/dist/md/idno.d.ts +2 -2
- package/dist/md/idno.js +1 -10
- package/dist/md/idno.js.map +1 -1
- package/dist/me/pib.d.ts +2 -2
- package/dist/me/pib.js +2 -10
- package/dist/me/pib.js.map +1 -1
- package/dist/mk/edb.d.ts +2 -2
- package/dist/mk/edb.js +2 -11
- package/dist/mk/edb.js.map +1 -1
- package/dist/mt/vat.d.ts +2 -2
- package/dist/mt/vat.js +3 -10
- package/dist/mt/vat.js.map +1 -1
- package/dist/mu/brn.d.ts +23 -2
- package/dist/mu/brn.js +1 -21
- package/dist/mu/brn.js.map +1 -1
- package/dist/mx/clabe.d.ts +2 -2
- package/dist/mx/clabe.js +1 -14
- package/dist/mx/clabe.js.map +1 -1
- package/dist/mx/curp.d.ts +2 -2
- package/dist/mx/curp.js +3 -17
- package/dist/mx/curp.js.map +1 -1
- package/dist/mx/rfc.d.ts +2 -2
- package/dist/mx/rfc.js +3 -19
- package/dist/mx/rfc.js.map +1 -1
- package/dist/my/nric.d.ts +2 -2
- package/dist/my/nric.js +2 -14
- package/dist/my/nric.js.map +1 -1
- package/dist/ng/nin.d.ts +13 -2
- package/dist/ng/nin.js +1 -11
- package/dist/ng/nin.js.map +1 -1
- package/dist/ni/ruc.d.ts +2 -2
- package/dist/ni/ruc.js +1 -23
- package/dist/ni/ruc.js.map +1 -1
- package/dist/nl/bsn.d.ts +2 -2
- package/dist/nl/bsn.js +2 -10
- package/dist/nl/bsn.js.map +1 -1
- package/dist/nl/kvk.d.ts +9 -2
- package/dist/nl/kvk.js +1 -7
- package/dist/nl/kvk.js.map +1 -1
- package/dist/nl/vat.d.ts +2 -2
- package/dist/nl/vat.js +1 -13
- package/dist/nl/vat.js.map +1 -1
- package/dist/no/fodselsnummer.d.ts +2 -2
- package/dist/no/fodselsnummer.js +2 -10
- package/dist/no/fodselsnummer.js.map +1 -1
- package/dist/no/mva.d.ts +2 -2
- package/dist/no/mva.js +1 -8
- package/dist/no/mva.js.map +1 -1
- package/dist/no/orgnr.d.ts +2 -2
- package/dist/no/orgnr.js +2 -8
- package/dist/no/orgnr.js.map +1 -1
- package/dist/nz/ird.d.ts +2 -2
- package/dist/nz/ird.js +2 -11
- package/dist/nz/ird.js.map +1 -1
- package/dist/pa/ruc.d.ts +2 -2
- package/dist/pa/ruc.js +1 -18
- package/dist/pa/ruc.js.map +1 -1
- package/dist/patterns.d.ts +8 -7
- package/dist/patterns.js +3 -5
- package/dist/patterns.js.map +1 -1
- package/dist/pe/ruc.d.ts +2 -2
- package/dist/pe/ruc.js +1 -15
- package/dist/pe/ruc.js.map +1 -1
- package/dist/ph/philid.d.ts +14 -2
- package/dist/ph/philid.js +1 -12
- package/dist/ph/philid.js.map +1 -1
- package/dist/pk/cnic.d.ts +14 -2
- package/dist/pk/cnic.js +1 -12
- package/dist/pk/cnic.js.map +1 -1
- package/dist/pl/nip.d.ts +2 -2
- package/dist/pl/nip.js +2 -10
- package/dist/pl/nip.js.map +1 -1
- package/dist/pl/pesel.d.ts +2 -2
- package/dist/pl/pesel.js +3 -13
- package/dist/pl/pesel.js.map +1 -1
- package/dist/pl/regon.d.ts +2 -2
- package/dist/pl/regon.js +2 -11
- package/dist/pl/regon.js.map +1 -1
- package/dist/pt/cc.d.ts +2 -2
- package/dist/pt/cc.js +1 -9
- package/dist/pt/cc.js.map +1 -1
- package/dist/pt/vat.d.ts +2 -2
- package/dist/pt/vat.js +3 -11
- package/dist/pt/vat.js.map +1 -1
- package/dist/ro/cnp.d.ts +2 -2
- package/dist/ro/cnp.js +4 -14
- package/dist/ro/cnp.js.map +1 -1
- package/dist/ro/vat.d.ts +2 -2
- package/dist/ro/vat.js +13 -11
- package/dist/ro/vat.js.map +1 -1
- package/dist/rs/pib.d.ts +2 -2
- package/dist/rs/pib.js +1 -9
- package/dist/rs/pib.js.map +1 -1
- package/dist/ru/inn.d.ts +2 -2
- package/dist/ru/inn.js +1 -11
- package/dist/ru/inn.js.map +1 -1
- package/dist/se/orgnr.d.ts +2 -2
- package/dist/se/orgnr.js +2 -9
- package/dist/se/orgnr.js.map +1 -1
- package/dist/se/personnummer.d.ts +2 -2
- package/dist/se/personnummer.js +7 -15
- package/dist/se/personnummer.js.map +1 -1
- package/dist/se/vat.d.ts +2 -2
- package/dist/se/vat.js +3 -10
- package/dist/se/vat.js.map +1 -1
- package/dist/sg/uen.d.ts +2 -2
- package/dist/sg/uen.js +1 -15
- package/dist/sg/uen.js.map +1 -1
- package/dist/si/emso.d.ts +2 -2
- package/dist/si/emso.js +3 -18
- package/dist/si/emso.js.map +1 -1
- package/dist/si/vat.d.ts +2 -2
- package/dist/si/vat.js +3 -12
- package/dist/si/vat.js.map +1 -1
- package/dist/sk/dic.d.ts +2 -2
- package/dist/sk/dic.js +1 -0
- package/dist/sk/dic.js.map +1 -1
- package/dist/sk/ico.d.ts +2 -2
- package/dist/sk/ico.js +1 -0
- package/dist/sk/ico.js.map +1 -1
- package/dist/sk/rc.d.ts +2 -2
- package/dist/sk/rc.js +1 -0
- package/dist/sk/rc.js.map +1 -1
- package/dist/th/tin.d.ts +2 -2
- package/dist/th/tin.js +1 -11
- package/dist/th/tin.js.map +1 -1
- package/dist/tr/tckimlik.d.ts +2 -2
- package/dist/tr/tckimlik.js +1 -20
- package/dist/tr/tckimlik.js.map +1 -1
- package/dist/tr/vkn.d.ts +2 -2
- package/dist/tr/vkn.js +1 -20
- package/dist/tr/vkn.js.map +1 -1
- package/dist/tw/ubn.d.ts +2 -2
- package/dist/tw/ubn.js +1 -11
- package/dist/tw/ubn.js.map +1 -1
- package/dist/types.d.ts +26 -4
- package/dist/ua/edrpou.d.ts +2 -2
- package/dist/ua/edrpou.js +1 -11
- package/dist/ua/edrpou.js.map +1 -1
- package/dist/us/ein.d.ts +12 -2
- package/dist/us/ein.js +1 -10
- package/dist/us/ein.js.map +1 -1
- package/dist/us/itin.d.ts +13 -2
- package/dist/us/itin.js +1 -11
- package/dist/us/itin.js.map +1 -1
- package/dist/us/rtn.d.ts +2 -2
- package/dist/us/rtn.js +3 -18
- package/dist/us/rtn.js.map +1 -1
- package/dist/us/ssn.d.ts +13 -2
- package/dist/us/ssn.js +1 -11
- package/dist/us/ssn.js.map +1 -1
- package/dist/uy/rut.d.ts +2 -2
- package/dist/uy/rut.js +1 -14
- package/dist/uy/rut.js.map +1 -1
- package/dist/ve/rif.d.ts +2 -2
- package/dist/ve/rif.js +2 -15
- package/dist/ve/rif.js.map +1 -1
- package/dist/vn/mst.d.ts +2 -2
- package/dist/vn/mst.js +1 -12
- package/dist/vn/mst.js.map +1 -1
- package/dist/za/idnr.d.ts +2 -2
- package/dist/za/idnr.js +3 -16
- package/dist/za/idnr.js.map +1 -1
- package/package.json +22 -12
- package/src/_checksums/mod1110.ts +1 -1
- package/src/ad/nrt.ts +7 -3
- package/src/ae/eid.ts +7 -3
- package/src/ai/tin.ts +7 -3
- package/src/al/nipt.ts +7 -3
- package/src/am/tin.ts +7 -3
- package/src/ar/cbu.ts +7 -3
- package/src/ar/cuit.ts +7 -3
- package/src/ar/dni.ts +7 -3
- package/src/at/businessid.ts +7 -3
- package/src/at/tin.ts +7 -3
- package/src/at/uid.ts +7 -3
- package/src/at/vnr.ts +37 -9
- package/src/au/abn.ts +7 -3
- package/src/au/acn.ts +7 -3
- package/src/au/tfn.ts +7 -3
- package/src/az/voen.ts +7 -3
- package/src/ba/jmbg.ts +8 -7
- package/src/bd/nid.ts +7 -3
- package/src/be/bis.ts +8 -4
- package/src/be/nn.ts +7 -3
- package/src/be/vat.ts +7 -3
- package/src/bg/egn.ts +8 -7
- package/src/bg/pnf.ts +7 -3
- package/src/bg/vat.ts +8 -3
- package/src/bh/cpr.ts +7 -3
- package/src/bic.ts +7 -3
- package/src/br/cnpj.ts +7 -3
- package/src/br/cpf.ts +7 -3
- package/src/by/unp.ts +10 -5
- package/src/bz/tin.ts +7 -3
- package/src/ca/bn.ts +7 -3
- package/src/ca/sin.ts +7 -3
- package/src/ch/ssn.ts +7 -3
- package/src/ch/uid.ts +7 -3
- package/src/ch/vat.ts +9 -5
- package/src/cl/rut.ts +7 -3
- package/src/cn/ric.ts +8 -7
- package/src/cn/uscc.ts +7 -3
- package/src/co/nit.ts +8 -4
- package/src/cr/cpf.ts +7 -3
- package/src/creditcard.ts +10 -6
- package/src/cu/ni.ts +8 -7
- package/src/cy/vat.ts +7 -3
- package/src/cz/dic.ts +9 -4
- package/src/cz/ico.ts +7 -3
- package/src/cz/rc.ts +8 -7
- package/src/de/handelsreg.ts +7 -3
- package/src/de/idnr.ts +7 -3
- package/src/de/stnr.ts +7 -3
- package/src/de/svnr.ts +7 -3
- package/src/de/vat.ts +7 -3
- package/src/dk/cpr.ts +8 -7
- package/src/dk/cvr.ts +7 -3
- package/src/dk/vat.ts +8 -3
- package/src/do/rnc.ts +7 -3
- package/src/ec/ruc.ts +7 -3
- package/src/ee/ik.ts +8 -7
- package/src/ee/registrikood.ts +8 -4
- package/src/ee/vat.ts +7 -3
- package/src/eg/tn.ts +7 -3
- package/src/es/cif.ts +8 -4
- package/src/es/dni.ts +7 -3
- package/src/es/nie.ts +8 -4
- package/src/es/nss.ts +7 -3
- package/src/es/vat.ts +13 -5
- package/src/eu/vat.ts +10 -6
- package/src/fi/hetu.ts +8 -7
- package/src/fi/vat.ts +8 -3
- package/src/fi/ytunnus.ts +7 -3
- package/src/fr/nif.ts +7 -3
- package/src/fr/nir.ts +8 -7
- package/src/fr/siren.ts +7 -3
- package/src/fr/siret.ts +7 -3
- package/src/fr/tva.ts +7 -3
- package/src/gb/nino.ts +7 -3
- package/src/gb/sedol.ts +7 -3
- package/src/gb/utr.ts +7 -3
- package/src/gb/vat.ts +7 -3
- package/src/ge/pin.ts +7 -3
- package/src/gh/tin.ts +7 -3
- package/src/gr/amka.ts +7 -3
- package/src/gr/vat.ts +7 -3
- package/src/gt/nit.ts +7 -3
- package/src/hk/hkid.ts +7 -3
- package/src/hr/vat.ts +7 -3
- package/src/hu/vat.ts +8 -3
- package/src/iban.ts +7 -3
- package/src/id/npwp.ts +7 -3
- package/src/ie/pps.ts +7 -3
- package/src/ie/vat.ts +7 -3
- package/src/il/idnr.ts +7 -3
- package/src/in/aadhaar.ts +7 -3
- package/src/in/gstin.ts +7 -3
- package/src/in/pan.ts +7 -3
- package/src/index.ts +3 -0
- package/src/iq/nid.ts +7 -3
- package/src/ir/nid.ts +7 -3
- package/src/is/kennitala.ts +7 -3
- package/src/is/vsk.ts +7 -3
- package/src/isin.ts +7 -3
- package/src/it/codicefiscale.ts +11 -7
- package/src/it/iva.ts +7 -3
- package/src/jp/cn.ts +7 -3
- package/src/jp/mynumber.ts +7 -3
- package/src/kr/brn.ts +7 -3
- package/src/kr/rrn.ts +8 -7
- package/src/kw/civil.ts +8 -7
- package/src/kz/iin.ts +8 -8
- package/src/lei.ts +7 -3
- package/src/li/peid.ts +7 -3
- package/src/lk/nic.ts +8 -7
- package/src/lt/asmens.ts +8 -4
- package/src/lt/vat.ts +8 -3
- package/src/lu/vat.ts +8 -3
- package/src/luhn.ts +7 -3
- package/src/lv/vat.ts +7 -3
- package/src/ma/ice.ts +7 -3
- package/src/mc/tva.ts +9 -5
- package/src/md/idno.ts +7 -3
- package/src/me/pib.ts +7 -3
- package/src/mk/edb.ts +7 -3
- package/src/mt/vat.ts +8 -3
- package/src/mu/brn.ts +7 -3
- package/src/mx/clabe.ts +7 -3
- package/src/mx/curp.ts +9 -8
- package/src/mx/rfc.ts +8 -4
- package/src/my/nric.ts +8 -7
- package/src/ng/nin.ts +7 -3
- package/src/ni/ruc.ts +7 -3
- package/src/nl/bsn.ts +7 -3
- package/src/nl/kvk.ts +7 -3
- package/src/nl/vat.ts +7 -3
- package/src/no/fodselsnummer.ts +11 -7
- package/src/no/mva.ts +9 -5
- package/src/no/orgnr.ts +7 -3
- package/src/nz/ird.ts +8 -4
- package/src/pa/ruc.ts +7 -3
- package/src/patterns.ts +49 -18
- package/src/pe/ruc.ts +7 -3
- package/src/ph/philid.ts +7 -3
- package/src/pk/cnic.ts +7 -3
- package/src/pl/nip.ts +7 -3
- package/src/pl/pesel.ts +8 -7
- package/src/pl/regon.ts +7 -3
- package/src/pt/cc.ts +7 -3
- package/src/pt/vat.ts +8 -3
- package/src/ro/cnp.ts +15 -8
- package/src/ro/vat.ts +8 -3
- package/src/rs/pib.ts +7 -3
- package/src/ru/inn.ts +7 -3
- package/src/se/orgnr.ts +7 -3
- package/src/se/personnummer.ts +35 -33
- package/src/se/vat.ts +8 -3
- package/src/sg/uen.ts +7 -3
- package/src/si/emso.ts +8 -7
- package/src/si/vat.ts +8 -3
- package/src/sk/dic.ts +8 -4
- package/src/sk/ico.ts +3 -2
- package/src/sk/rc.ts +6 -2
- package/src/th/tin.ts +7 -3
- package/src/tr/tckimlik.ts +7 -3
- package/src/tr/vkn.ts +7 -3
- package/src/tw/ubn.ts +7 -3
- package/src/types.ts +34 -3
- package/src/ua/edrpou.ts +7 -3
- package/src/us/ein.ts +7 -3
- package/src/us/itin.ts +7 -3
- package/src/us/rtn.ts +16 -8
- package/src/us/ssn.ts +7 -3
- package/src/uy/rut.ts +7 -3
- package/src/ve/rif.ts +8 -6
- package/src/vn/mst.ts +7 -3
- package/src/za/idnr.ts +8 -7
package/dist/kr/rrn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrn.js","names":[],"sources":["../../src/kr/rrn.ts"],"sourcesContent":["/**\n * RRN (Resident Registration Number, 주민등록번호).\n *\n * Korean Resident Registration Number. 13 digits\n * formatted as YYMMDD-GPPCCSD. Encodes date of\n * birth, gender/century, place of birth, community\n * center, serial, and a check digit.\n *\n * @see https://en.wikipedia.org/wiki/Resident_registration_number\n */\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"rrn.js","names":[],"sources":["../../src/kr/rrn.ts"],"sourcesContent":["/**\n * RRN (Resident Registration Number, 주민등록번호).\n *\n * Korean Resident Registration Number. 13 digits\n * formatted as YYMMDD-GPPCCSD. Encodes date of\n * birth, gender/century, place of birth, community\n * center, serial, and a check digit.\n *\n * @see https://en.wikipedia.org/wiki/Resident_registration_number\n */\n\nimport type {\n ParsedPersonId,\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\nconst compact = (value: string): string =>\n clean(value, \" -/\");\n\nconst CHECK_WEIGHTS = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];\n\n/**\n * Compute the check digit for the first 12 digits.\n * Formula: (11 - sum(w_i * d_i) % 11) % 10.\n */\nconst checkDigit = (digits: string): number => {\n let sum = 0;\n for (let i = 0; i < 12; i++) {\n sum +=\n (CHECK_WEIGHTS[i] ?? 0) * Number(digits.charAt(i));\n }\n return (11 - (sum % 11)) % 10;\n};\n\n/** Century prefix derived from the 7th digit. */\nconst CENTURY_BY_GENDER: Record<string, number> = {\n \"0\": 1800,\n \"1\": 1900,\n \"2\": 1900,\n \"3\": 2000,\n \"4\": 2000,\n \"5\": 1900,\n \"6\": 1900,\n \"7\": 2000,\n \"8\": 2000,\n \"9\": 1800,\n};\n\n/**\n * Resolve birth date components from a compacted RRN.\n * Returns null if the date is invalid.\n */\nconst resolveBirthDate = (\n v: string,\n): { year: number; month: number; day: number } | null => {\n const century = CENTURY_BY_GENDER[v.charAt(6)];\n if (century === undefined) return null;\n\n const year = century + Number(v.slice(0, 2));\n const month = Number(v.slice(2, 4));\n const day = Number(v.slice(4, 6));\n\n if (!isValidDate(year, month, day)) return null;\n return { year, month, day };\n};\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n if (v.length !== 13) {\n return err(\n \"INVALID_LENGTH\",\n \"RRN must be exactly 13 digits\",\n );\n }\n if (!isdigits(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"RRN must contain only digits\",\n );\n }\n if (resolveBirthDate(v) === null) {\n return err(\n \"INVALID_COMPONENT\",\n \"RRN contains an invalid date of birth\",\n );\n }\n const place = Number(v.slice(7, 9));\n if (place > 96) {\n return err(\n \"INVALID_COMPONENT\",\n \"RRN place-of-birth code must be <= 96\",\n );\n }\n if (checkDigit(v.slice(0, 12)) !== Number(v[12])) {\n return err(\n \"INVALID_CHECKSUM\",\n \"RRN check digit does not match\",\n );\n }\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => {\n const v = compact(value);\n if (v.length === 13) {\n return `${v.slice(0, 6)}-${v.slice(6)}`;\n }\n return v;\n};\n\n/**\n * Extract birth date and gender from an RRN.\n * Returns null if the value is not valid.\n *\n * Gender digit mapping:\n * 1, 3 = male Korean; 2, 4 = female Korean\n * 5, 7 = male foreigner; 6, 8 = female foreigner\n * 0, 9 = pre-1800 (male/female by convention)\n */\nconst parse = (value: string): ParsedPersonId | null => {\n const result = validate(value);\n if (!result.valid) return null;\n\n const v = result.compact;\n const bd = resolveBirthDate(v);\n if (bd === null) return null;\n\n const genderDigit = v.charAt(6);\n const isMale = \"13579\".includes(genderDigit);\n\n return {\n birthDate: new Date(bd.year, bd.month - 1, bd.day),\n gender: isMale ? \"male\" : \"female\",\n };\n};\n\n/** Generate a random valid Korean RRN. */\nconst generate = (): string => {\n const year = randomInt(1900, 2024);\n const month = String(randomInt(1, 12)).padStart(2, \"0\");\n const day = String(randomInt(1, 28)).padStart(2, \"0\");\n const yy = String(year % 100).padStart(2, \"0\");\n const genderDigit =\n year >= 2000\n ? String(randomInt(3, 4))\n : String(randomInt(1, 2));\n const place = String(randomInt(0, 96)).padStart(2, \"0\");\n const body = `${yy}${month}${day}${genderDigit}${place}${randomDigits(3)}`;\n return `${body}${String(checkDigit(body))}`;\n};\n\n/** Korean Resident Registration Number. */\nconst rrn: CountryValidator<\"KR\", ParsedPersonId> = {\n name: \"Korean Resident Registration Number\",\n localName: \"주민등록번호\",\n abbreviation: \"RRN\",\n aliases: [\n \"RRN\",\n \"주민등록번호\",\n \"Resident Registration Number\",\n ] as const,\n candidatePattern: \"\\\\d{6}[\\\\s-]?\\\\d{7}\",\n scope: \"country\",\n country: \"KR\",\n entityType: \"person\",\n description:\n \"13-digit personal identifier issued to all\" +\n \" residents of South Korea\",\n sourceUrl:\n \"https://en.wikipedia.org/wiki/\" +\n \"Resident_registration_number\",\n lengths: [13] as const,\n examples: [\"9710139019902\", \"9501011000109\"] as const,\n compact,\n format,\n parse,\n validate,\n generate,\n};\n\nexport default rrn;\nexport { compact, format, generate, parse, validate };\n"],"mappings":";;;;;;AAuBA,MAAM,WAAW,UACf,MAAM,OAAO,KAAK;AAEpB,MAAM,gBAAgB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC;;;;;AAMzD,MAAM,cAAc,WAA2B;CAC7C,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI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ValidateResult
|
|
1
|
+
import { CountryValidator, ParsedBirthDate, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/kw/civil.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -13,7 +13,7 @@ declare const parse: (value: string) => ParsedBirthDate | null;
|
|
|
13
13
|
/** Generate a random valid Kuwait civil number. */
|
|
14
14
|
declare const generate: () => string;
|
|
15
15
|
/** Kuwait Civil Number (الرقم المدني). */
|
|
16
|
-
declare const civil:
|
|
16
|
+
declare const civil: CountryValidator<"KW", ParsedBirthDate>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { compact, civil as default, format, generate, parse, validate };
|
|
19
19
|
//# sourceMappingURL=civil.d.ts.map
|
package/dist/kw/civil.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import { clean } from "../_util/clean.js";
|
|
2
|
+
import { isValidDate } from "../_util/date.js";
|
|
2
3
|
import { randomDigits, randomInt } from "../_util/generate.js";
|
|
3
4
|
import { err } from "../_util/result.js";
|
|
4
5
|
import { isdigits } from "../_util/strings.js";
|
|
5
|
-
import { isValidDate } from "../_util/date.js";
|
|
6
6
|
//#region src/kw/civil.ts
|
|
7
|
-
/**
|
|
8
|
-
* Civil Number (الرقم المدني, Kuwait).
|
|
9
|
-
*
|
|
10
|
-
* 12-digit number issued by PACI (Public Authority
|
|
11
|
-
* for Civil Information):
|
|
12
|
-
* C = century indicator (2 = 1900s, 3 = 2000s)
|
|
13
|
-
* YYMMDD = birth date
|
|
14
|
-
* SSSS = serial number
|
|
15
|
-
* K = check digit (mod 11 weighted sum)
|
|
16
|
-
*
|
|
17
|
-
* @see https://prakhar.me/articles/kuwait-civil-id-checksum/
|
|
18
|
-
* @see https://kuwaitsexpat.com/kuwait-civil-id-format/
|
|
19
|
-
*/
|
|
20
7
|
const WEIGHTS = [
|
|
21
8
|
2,
|
|
22
9
|
1,
|
|
@@ -96,6 +83,7 @@ const civil = {
|
|
|
96
83
|
abbreviation: "Civil ID",
|
|
97
84
|
aliases: ["Civil ID", "الرقم المدني"],
|
|
98
85
|
candidatePattern: "\\d{12}",
|
|
86
|
+
scope: "country",
|
|
99
87
|
country: "KW",
|
|
100
88
|
entityType: "person",
|
|
101
89
|
lengths: [12],
|
package/dist/kw/civil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"civil.js","names":[],"sources":["../../src/kw/civil.ts"],"sourcesContent":["/**\n * Civil Number (الرقم المدني, Kuwait).\n *\n * 12-digit number issued by PACI (Public Authority\n * for Civil Information):\n * C = century indicator (2 = 1900s, 3 = 2000s)\n * YYMMDD = birth date\n * SSSS = serial number\n * K = check digit (mod 11 weighted sum)\n *\n * @see https://prakhar.me/articles/kuwait-civil-id-checksum/\n * @see https://kuwaitsexpat.com/kuwait-civil-id-format/\n */\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"civil.js","names":[],"sources":["../../src/kw/civil.ts"],"sourcesContent":["/**\n * Civil Number (الرقم المدني, Kuwait).\n *\n * 12-digit number issued by PACI (Public Authority\n * for Civil Information):\n * C = century indicator (2 = 1900s, 3 = 2000s)\n * YYMMDD = birth date\n * SSSS = serial number\n * K = check digit (mod 11 weighted sum)\n *\n * @see https://prakhar.me/articles/kuwait-civil-id-checksum/\n * @see https://kuwaitsexpat.com/kuwait-civil-id-format/\n */\n\nimport type {\n ParsedBirthDate,\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\nconst WEIGHTS = [2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] as const;\n\nconst centuryMap: Record<number, number> = {\n 2: 1900,\n 3: 2000,\n};\n\nconst compact = (value: string): string =>\n clean(value, \" -\");\n\nconst calcCheckDigit = (digits: string): number => {\n let sum = 0;\n for (const [i, weight] of WEIGHTS.entries()) {\n sum += Number(digits[i]) * weight;\n }\n return (11 - (sum % 11)) % 11;\n};\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n\n if (v.length !== 12) {\n return err(\n \"INVALID_LENGTH\",\n \"Kuwait civil number must be 12 digits\",\n );\n }\n\n if (!isdigits(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"Kuwait civil number must contain only digits\",\n );\n }\n\n const centuryDigit = Number(v[0]);\n if (centuryDigit !== 2 && centuryDigit !== 3) {\n return err(\n \"INVALID_COMPONENT\",\n \"Century digit must be 2 or 3\",\n );\n }\n\n const yearBase = centuryMap[centuryDigit] ?? 1900;\n const yy = Number(v.slice(1, 3));\n const mm = Number(v.slice(3, 5));\n const dd = Number(v.slice(5, 7));\n const year = yearBase + yy;\n\n if (!isValidDate(year, mm, dd)) {\n return err(\n \"INVALID_COMPONENT\",\n \"Civil number contains an invalid birth date\",\n );\n }\n\n const expected = calcCheckDigit(v.slice(0, 11));\n if (expected !== Number(v[11])) {\n return err(\n \"INVALID_CHECKSUM\",\n \"Civil number check digit does not match\",\n );\n }\n\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => {\n const v = compact(value);\n return `${v.slice(0, 1)} ${v.slice(1, 7)} ${v.slice(7, 11)} ${v.slice(11)}`;\n};\n\n/**\n * Extract birth date from a Kuwait civil number.\n * Gender is not encoded in the number.\n * Returns null if the value is not valid.\n */\nconst parse = (value: string): ParsedBirthDate | null => {\n const result = validate(value);\n if (!result.valid) return null;\n\n const v = result.compact;\n const centuryDigit = Number(v[0]);\n const yearBase = centuryMap[centuryDigit] ?? 1900;\n const yy = Number(v.slice(1, 3));\n const mm = Number(v.slice(3, 5));\n const dd = Number(v.slice(5, 7));\n const year = yearBase + yy;\n\n return {\n birthDate: new Date(year, mm - 1, dd),\n };\n};\n\n/** Generate a random valid Kuwait civil number. */\nconst generate = (): string => {\n for (;;) {\n const year = randomInt(1950, 2024);\n const month = String(randomInt(1, 12)).padStart(2, \"0\");\n const day = String(randomInt(1, 28)).padStart(2, \"0\");\n const body =\n `${year >= 2000 ? \"3\" : \"2\"}` +\n `${String(year % 100).padStart(2, \"0\")}` +\n `${month}${day}${randomDigits(4)}`;\n const check = calcCheckDigit(body);\n if (check > 9) continue;\n return `${body}${String(check)}`;\n }\n};\n\n/** Kuwait Civil Number (الرقم المدني). */\nconst civil: CountryValidator<\"KW\", ParsedBirthDate> = {\n name: \"Civil Number\",\n localName: \"الرقم المدني\",\n abbreviation: \"Civil ID\",\n aliases: [\"Civil ID\", \"الرقم المدني\"] as const,\n candidatePattern: \"\\\\d{12}\",\n scope: \"country\",\n country: \"KW\",\n entityType: \"person\",\n lengths: [12] as const,\n examples: [\"289011200032\", \"305031512348\"] as const,\n description:\n \"12-digit civil identification number issued by PACI\",\n sourceUrl:\n \"https://kuwaitsexpat.com/kuwait-civil-id-format/\",\n compact,\n format,\n parse,\n validate,\n generate,\n};\n\nexport default civil;\nexport { compact, format, generate, parse, validate };\n"],"mappings":";;;;;;AA0BA,MAAM,UAAU;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAI;CAAG;CAAG;CAAG;AAAC;AAEjD,MAAM,aAAqC;CACzC,GAAG;CACH,GAAG;AACL;AAEA,MAAM,WAAW,UACf,MAAM,OAAO,IAAI;AAEnB,MAAM,kBAAkB,WAA2B;CACjD,IAAI,MAAM;CACV,KAAK,MAAM,CAAC,GAAG,WAAW,QAAQ,QAAQ,GACxC,OAAO,OAAO,OAAO,EAAE,IAAI;CAE7B,QAAQ,KAAM,MAAM,MAAO;AAC7B;AAEA,MAAM,YAAY,UAAkC;CAClD,MAAM,IAAI,QAAQ,KAAK;CAEvB,IAAI,EAAE,WAAW,IACf,OAAO,IACL,kBACA,uCACF;CAGF,IAAI,CAAC,SAAS,CAAC,GACb,OAAO,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AAO,UAAU,MAAM,IAAI;EACjC,MAAM,QAAQ,OAAO,UAAU,GAAG,EAAE,CAAC,EAAE,SAAS,GAAG,GAAG;EACtD,MAAM,MAAM,OAAO,UAAU,GAAG,EAAE,CAAC,EAAE,SAAS,GAAG,GAAG;EACpD,MAAM,OACJ,GAAG,QAAQ,MAAO,MAAM,MACrB,OAAO,OAAO,GAAG,EAAE,SAAS,GAAG,GAAG,IAClC,QAAQ,MAAM,aAAa,CAAC;EACjC,MAAM,QAAQ,eAAe,IAAI;EACjC,IAAI,QAAQ,GAAG;EACf,OAAO,GAAG,OAAO,OAAO,KAAK;CAC/B;AACF;;AAGA,MAAM,QAAiD;CACrD,MAAM;CACN,WAAW;CACX,cAAc;CACd,SAAS,CAAC,YAAY,cAAc;CACpC,kBAAkB;CAClB,OAAO;CACP,SAAS;CACT,YAAY;CACZ,SAAS,CAAC,EAAE;CACZ,UAAU,CAAC,gBAAgB,cAAc;CACzC,aACE;CACF,WACE;CACF;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/kz/iin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsedPersonId, ValidateResult
|
|
1
|
+
import { CountryValidator, ParsedPersonId, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/kz/iin.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -16,7 +16,7 @@ declare const generate: () => string;
|
|
|
16
16
|
*
|
|
17
17
|
* Examples sourced from identique/idnumbers test suite.
|
|
18
18
|
*/
|
|
19
|
-
declare const iin:
|
|
19
|
+
declare const iin: CountryValidator<"KZ", ParsedPersonId>;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { compact, iin as default, format, generate, parse, validate };
|
|
22
22
|
//# sourceMappingURL=iin.d.ts.map
|
package/dist/kz/iin.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
+
import { weightedSum } from "../_checksums/weighted-sum.js";
|
|
1
2
|
import { clean } from "../_util/clean.js";
|
|
3
|
+
import { isValidDate } from "../_util/date.js";
|
|
2
4
|
import { randomDigits, randomInt } from "../_util/generate.js";
|
|
3
5
|
import { err } from "../_util/result.js";
|
|
4
6
|
import { isdigits } from "../_util/strings.js";
|
|
5
|
-
import { weightedSum } from "../_checksums/weighted-sum.js";
|
|
6
|
-
import { isValidDate } from "../_util/date.js";
|
|
7
7
|
//#region src/kz/iin.ts
|
|
8
|
-
/**
|
|
9
|
-
* IIN (Individual Identification Number,
|
|
10
|
-
* Жеке сәйкестендіру нөмірі / ИИН).
|
|
11
|
-
*
|
|
12
|
-
* Kazakhstan individual identification number. 12 digits:
|
|
13
|
-
* YYMMDD = birth date
|
|
14
|
-
* C = century/gender (1-6)
|
|
15
|
-
* SSSS = serial number
|
|
16
|
-
* K = check digit (two-pass weighted sum mod 11)
|
|
17
|
-
*
|
|
18
|
-
* Odd century digits = male, even = female.
|
|
19
|
-
* 1-2 = 1800s, 3-4 = 1900s, 5-6 = 2000s.
|
|
20
|
-
*
|
|
21
|
-
* @see https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Kazakhstan-TIN.pdf
|
|
22
|
-
*/
|
|
23
8
|
const WEIGHTS_1 = [
|
|
24
9
|
1,
|
|
25
10
|
2,
|
|
@@ -114,7 +99,6 @@ const generate = () => {
|
|
|
114
99
|
const serial = randomDigits(4);
|
|
115
100
|
const payload = yy + mm + dd + gender + serial;
|
|
116
101
|
const check = calcCheckDigit(payload);
|
|
117
|
-
if (check === null) continue;
|
|
118
102
|
const c = payload + String(check);
|
|
119
103
|
if (validate(c).valid) return c;
|
|
120
104
|
}
|
|
@@ -134,6 +118,7 @@ const iin = {
|
|
|
134
118
|
"индивидуальный идентификационный номер"
|
|
135
119
|
],
|
|
136
120
|
candidatePattern: "\\d{12}",
|
|
121
|
+
scope: "country",
|
|
137
122
|
country: "KZ",
|
|
138
123
|
entityType: "person",
|
|
139
124
|
lengths: [12],
|
package/dist/kz/iin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iin.js","names":[],"sources":["../../src/kz/iin.ts"],"sourcesContent":["/**\n * IIN (Individual Identification Number,\n * Жеке сәйкестендіру нөмірі / ИИН).\n *\n * Kazakhstan individual identification number. 12 digits:\n * YYMMDD = birth date\n * C = century/gender (1-6)\n * SSSS = serial number\n * K = check digit (two-pass weighted sum mod 11)\n *\n * Odd century digits = male, even = female.\n * 1-2 = 1800s, 3-4 = 1900s, 5-6 = 2000s.\n *\n * @see https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Kazakhstan-TIN.pdf\n */\n\nimport { weightedSum } from \"#checksums/weighted-sum\";\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"iin.js","names":[],"sources":["../../src/kz/iin.ts"],"sourcesContent":["/**\n * IIN (Individual Identification Number,\n * Жеке сәйкестендіру нөмірі / ИИН).\n *\n * Kazakhstan individual identification number. 12 digits:\n * YYMMDD = birth date\n * C = century/gender (1-6)\n * SSSS = serial number\n * K = check digit (two-pass weighted sum mod 11)\n *\n * Odd century digits = male, even = female.\n * 1-2 = 1800s, 3-4 = 1900s, 5-6 = 2000s.\n *\n * @see https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Kazakhstan-TIN.pdf\n */\n\nimport type {\n ParsedPersonId,\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { weightedSum } from \"#checksums/weighted-sum\";\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\nconst WEIGHTS_1 = [\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\n] as const;\nconst WEIGHTS_2 = [\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2,\n] as const;\n\nconst centuryMap: Record<number, number> = {\n 1: 1800,\n 2: 1800,\n 3: 1900,\n 4: 1900,\n 5: 2000,\n 6: 2000,\n};\n\nconst compact = (value: string): string =>\n clean(value, \" -\").trim();\n\n/**\n * Two-pass check digit: weighted sum mod 11 with\n * fallback to second weight set.\n */\nconst calcCheckDigit = (digits: string): number => {\n let remainder = weightedSum(digits, WEIGHTS_1, 11);\n if (remainder === 10) {\n remainder = weightedSum(digits, WEIGHTS_2, 11);\n }\n return remainder === 10 ? 0 : remainder;\n};\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n\n if (v.length !== 12) {\n return err(\n \"INVALID_LENGTH\",\n \"Kazakhstan IIN must be 12 digits\",\n );\n }\n\n if (!isdigits(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"Kazakhstan IIN must contain only digits\",\n );\n }\n\n const centuryDigit = Number(v[6]);\n if (centuryDigit < 1 || centuryDigit > 6) {\n return err(\n \"INVALID_COMPONENT\",\n \"IIN century/gender digit must be 1-6\",\n );\n }\n\n const yearBase = centuryMap[centuryDigit] ?? 1900;\n const yy = Number(v.slice(0, 2));\n const mm = Number(v.slice(2, 4));\n const dd = Number(v.slice(4, 6));\n const year = yearBase + yy;\n\n if (!isValidDate(year, mm, dd)) {\n return err(\n \"INVALID_COMPONENT\",\n \"IIN contains an invalid birth date\",\n );\n }\n\n const expected = calcCheckDigit(v.slice(0, 11));\n if (expected !== Number(v[11])) {\n return err(\n \"INVALID_CHECKSUM\",\n \"IIN check digit does not match\",\n );\n }\n\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => {\n const v = compact(value);\n return `${v.slice(0, 6)} ${v.slice(6)}`;\n};\n\n/**\n * Extract birth date and gender from a Kazakhstan IIN.\n * Returns null if the value is not valid.\n */\nconst parse = (value: string): ParsedPersonId | null => {\n const result = validate(value);\n if (!result.valid) return null;\n\n const v = result.compact;\n const centuryDigit = Number(v[6]);\n const yearBase = centuryMap[centuryDigit] ?? 1900;\n const yy = Number(v.slice(0, 2));\n const mm = Number(v.slice(2, 4));\n const dd = Number(v.slice(4, 6));\n const year = yearBase + yy;\n\n return {\n birthDate: new Date(year, mm - 1, dd),\n gender: centuryDigit % 2 === 1 ? \"male\" : \"female\",\n };\n};\n\n/** Generate a random valid Kazakhstan IIN. */\nconst generate = (): string => {\n for (;;) {\n const yy = String(randomInt(50, 99)).padStart(2, \"0\");\n const mm = String(randomInt(1, 12)).padStart(2, \"0\");\n const dd = String(randomInt(1, 28)).padStart(2, \"0\");\n const gender = String(randomInt(1, 6));\n const serial = randomDigits(4);\n const payload = yy + mm + dd + gender + serial;\n const check = calcCheckDigit(payload);\n const c = payload + String(check);\n if (validate(c).valid) return c;\n }\n};\n\n/**\n * Kazakhstan Individual Identification Number (IIN).\n *\n * Examples sourced from identique/idnumbers test suite.\n */\nconst iin: CountryValidator<\"KZ\", ParsedPersonId> = {\n name: \"Kazakhstan Individual ID\",\n localName: \"Жеке сәйкестендіру нөмірі\",\n abbreviation: \"IIN\",\n aliases: [\n \"ИИН\",\n \"IIN\",\n \"индивидуальный идентификационный номер\",\n ] as const,\n candidatePattern: \"\\\\d{12}\",\n scope: \"country\",\n country: \"KZ\",\n entityType: \"person\",\n lengths: [12] as const,\n examples: [\"880515300120\", \"950101400012\"] as const,\n compact,\n format,\n parse,\n validate,\n sourceUrl:\n \"https://www.oecd.org/tax/automatic-exchange/\" +\n \"crs-implementation-and-assistance/\" +\n \"tax-identification-numbers/Kazakhstan-TIN.pdf\",\n generate,\n};\n\nexport default iin;\nexport { compact, format, parse, validate, generate };\n"],"mappings":";;;;;;;AA6BA,MAAM,YAAY;CAChB;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAI;AACjC;AACA,MAAM,YAAY;CAChB;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAI;CAAI;CAAG;AAClC;AAEA,MAAM,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|
|
3
3
|
//#region src/lei.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -7,7 +7,7 @@ declare const format: (value: string) => string;
|
|
|
7
7
|
/** Generate a random valid LEI. */
|
|
8
8
|
declare const generate: () => string;
|
|
9
9
|
/** Legal Entity Identifier. */
|
|
10
|
-
declare const lei:
|
|
10
|
+
declare const lei: GlobalValidator;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { compact, lei as default, format, generate, validate };
|
|
13
13
|
//# sourceMappingURL=lei.d.ts.map
|
package/dist/lei.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
+
import { mod97 } from "./_checksums/mod97.js";
|
|
1
2
|
import { clean } from "./_util/clean.js";
|
|
2
3
|
import { randomInt } from "./_util/generate.js";
|
|
3
4
|
import { err } from "./_util/result.js";
|
|
4
5
|
import { charValue, isalnum } from "./_util/strings.js";
|
|
5
|
-
import { mod97 } from "./_checksums/mod97.js";
|
|
6
6
|
//#region src/lei.ts
|
|
7
|
-
/**
|
|
8
|
-
* LEI (Legal Entity Identifier).
|
|
9
|
-
*
|
|
10
|
-
* ISO 17442. 20-character alphanumeric code
|
|
11
|
-
* identifying legal entities in financial
|
|
12
|
-
* transactions. Validated using ISO 7064
|
|
13
|
-
* Mod 97-10 (same as IBAN).
|
|
14
|
-
*
|
|
15
|
-
* @see https://www.gleif.org/
|
|
16
|
-
*/
|
|
17
7
|
const compact = (value) => clean(value, " -").toUpperCase();
|
|
18
8
|
const validate = (value) => {
|
|
19
9
|
const v = compact(value);
|
|
@@ -49,6 +39,7 @@ const generate = () => {
|
|
|
49
39
|
};
|
|
50
40
|
/** Legal Entity Identifier. */
|
|
51
41
|
const lei = {
|
|
42
|
+
scope: "global",
|
|
52
43
|
name: "Legal Entity Identifier",
|
|
53
44
|
localName: "Legal Entity Identifier",
|
|
54
45
|
abbreviation: "LEI",
|
package/dist/lei.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lei.js","names":[],"sources":["../src/lei.ts"],"sourcesContent":["/**\n * LEI (Legal Entity Identifier).\n *\n * ISO 17442. 20-character alphanumeric code\n * identifying legal entities in financial\n * transactions. Validated using ISO 7064\n * Mod 97-10 (same as IBAN).\n *\n * @see https://www.gleif.org/\n */\n\nimport { mod97 } from \"#checksums/mod97\";\nimport { clean } from \"#util/clean\";\nimport { randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { charValue, isalnum } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"lei.js","names":[],"sources":["../src/lei.ts"],"sourcesContent":["/**\n * LEI (Legal Entity Identifier).\n *\n * ISO 17442. 20-character alphanumeric code\n * identifying legal entities in financial\n * transactions. Validated using ISO 7064\n * Mod 97-10 (same as IBAN).\n *\n * @see https://www.gleif.org/\n */\n\nimport type {\n ValidateResult,\n GlobalValidator,\n} from \"./types\";\n\nimport { mod97 } from \"#checksums/mod97\";\nimport { clean } from \"#util/clean\";\nimport { randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { charValue, isalnum } from \"#util/strings\";\n\nconst compact = (value: string): string =>\n clean(value, \" -\").toUpperCase();\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n if (v.length !== 20) {\n return err(\n \"INVALID_LENGTH\",\n \"LEI must be exactly 20 characters\",\n );\n }\n if (!isalnum(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"LEI must contain only letters and digits\",\n );\n }\n // Characters 5-18 must be alphanumeric (entity)\n // Characters 19-20 are check digits (numeric)\n const checkPart = v.slice(18);\n if (!/^\\d{2}$/.test(checkPart)) {\n return err(\n \"INVALID_FORMAT\",\n \"LEI check digits must be numeric\",\n );\n }\n // Convert to numeric and validate mod 97\n let numeric = \"\";\n for (let i = 0; i < v.length; i++) {\n const ch = v[i];\n if (ch !== undefined) {\n numeric += String(charValue(ch));\n }\n }\n if (mod97(numeric) !== 1) {\n return err(\n \"INVALID_CHECKSUM\",\n \"LEI check digits are incorrect\",\n );\n }\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => {\n const v = compact(value);\n return `${v.slice(0, 4)} ${v.slice(4, 8)} ${v.slice(8, 12)} ${v.slice(12, 16)} ${v.slice(16)}`;\n};\n\n/** Generate a random valid LEI. */\nconst generate = (): string => {\n for (;;) {\n let base = \"\";\n for (let i = 0; i < 18; i++)\n base += String(randomInt(0, 9));\n for (let cd = 0; cd < 100; cd++) {\n const c = base + String(cd).padStart(2, \"0\");\n if (validate(c).valid) return c;\n }\n }\n};\n\n/** Legal Entity Identifier. */\nconst lei: GlobalValidator = {\n scope: \"global\",\n name: \"Legal Entity Identifier\",\n localName: \"Legal Entity Identifier\",\n abbreviation: \"LEI\",\n aliases: [\"LEI\", \"Legal Entity Identifier\"] as const,\n candidatePattern: \"[A-Z0-9]{18}\\\\d{2}\",\n entityType: \"company\",\n sourceUrl: \"https://www.gleif.org/\",\n examples: [\"5493006MHB84DD0ZWV18\"] as const,\n compact,\n format,\n validate,\n generate,\n};\n\nexport default lei;\nexport { compact, format, validate, generate };\n"],"mappings":";;;;;;AAsBA,MAAM,WAAW,UACf,MAAM,OAAO,IAAI,EAAE,YAAY;AAEjC,MAAM,YAAY,UAAkC;CAClD,MAAM,IAAI,QAAQ,KAAK;CACvB,IAAI,EAAE,WAAW,IACf,OAAO,IACL,kBACA,mCACF;CAEF,IAAI,CAAC,QAAQ,CAAC,GACZ,OAAO,IACL,kBACA,0CACF;CAIF,MAAM,YAAY,EAAE,MAAM,EAAE;CAC5B,IAAI,CAAC,UAAU,KAAK,SAAS,GAC3B,OAAO,IACL,kBACA,kCACF;CAGF,IAAI,UAAU;CACd,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;EACjC,MAAM,KAAK,EAAE;EACb,IAAI,OAAO,KAAA,GACT,WAAW,OAAO,UAAU,EAAE,CAAC;CAEnC;CACA,IAAI,MAAM,OAAO,MAAM,GACrB,OAAO,IACL,oBACA,gCACF;CAEF,OAAO;EAAE,OAAO;EAAM,SAAS;CAAE;AACnC;AAEA,MAAM,UAAU,UAA0B;CACxC,MAAM,IAAI,QAAQ,KAAK;CACvB,OAAO,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;AAC7F;;AAGA,MAAM,iBAAyB;CAC7B,SAAS;EACP,IAAI,OAAO;EACX,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KACtB,QAAQ,OAAO,UAAU,GAAG,CAAC,CAAC;EAChC,KAAK,IAAI,KAAK,GAAG,KAAK,KAAK,MAAM;GAC/B,MAAM,IAAI,OAAO,OAAO,EAAE,EAAE,SAAS,GAAG,GAAG;GAC3C,IAAI,SAAS,CAAC,EAAE,OAAO,OAAO;EAChC;CACF;AACF;;AAGA,MAAM,MAAuB;CAC3B,OAAO;CACP,MAAM;CACN,WAAW;CACX,cAAc;CACd,SAAS,CAAC,OAAO,yBAAyB;CAC1C,kBAAkB;CAClB,YAAY;CACZ,WAAW;CACX,UAAU,CAAC,sBAAsB;CACjC;CACA;CACA;CACA;AACF"}
|
package/dist/li/peid.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CountryValidator, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/li/peid.d.ts
|
|
4
4
|
/** Generate a random valid Liechtenstein PEID. */
|
|
5
5
|
declare const generate: () => string;
|
|
6
|
+
/**
|
|
7
|
+
* PEID (Personenidentifikationsnummer).
|
|
8
|
+
*
|
|
9
|
+
* Liechtenstein tax code for individuals and entities.
|
|
10
|
+
* Numeric code of 4 to 12 digits, with leading zeros
|
|
11
|
+
* stripped during compaction.
|
|
12
|
+
*
|
|
13
|
+
* @see https://www.oera.li/
|
|
14
|
+
*/
|
|
6
15
|
declare const compact: (value: string) => string;
|
|
7
16
|
declare const validate: (value: string) => ValidateResult;
|
|
8
17
|
declare const format: (value: string) => string;
|
|
9
18
|
/** Liechtenstein Person Identification Number. */
|
|
10
|
-
declare const peid:
|
|
19
|
+
declare const peid: CountryValidator<"LI">;
|
|
11
20
|
//#endregion
|
|
12
21
|
export { compact, peid as default, format, generate, validate };
|
|
13
22
|
//# sourceMappingURL=peid.d.ts.map
|
package/dist/li/peid.js
CHANGED
|
@@ -3,15 +3,6 @@ import { randomDigits, randomInt } from "../_util/generate.js";
|
|
|
3
3
|
import { err } from "../_util/result.js";
|
|
4
4
|
import { isdigits } from "../_util/strings.js";
|
|
5
5
|
//#region src/li/peid.ts
|
|
6
|
-
/**
|
|
7
|
-
* PEID (Personenidentifikationsnummer).
|
|
8
|
-
*
|
|
9
|
-
* Liechtenstein tax code for individuals and entities.
|
|
10
|
-
* Numeric code of 4 to 12 digits, with leading zeros
|
|
11
|
-
* stripped during compaction.
|
|
12
|
-
*
|
|
13
|
-
* @see https://www.oera.li/
|
|
14
|
-
*/
|
|
15
6
|
/** Generate a random valid Liechtenstein PEID. */
|
|
16
7
|
const generate = () => {
|
|
17
8
|
const len = randomInt(4, 12);
|
|
@@ -35,6 +26,7 @@ const peid = {
|
|
|
35
26
|
abbreviation: "PEID",
|
|
36
27
|
aliases: ["PEID", "Personenidentifikation"],
|
|
37
28
|
candidatePattern: "\\d{6}",
|
|
29
|
+
scope: "country",
|
|
38
30
|
country: "LI",
|
|
39
31
|
entityType: "any",
|
|
40
32
|
lengths: [
|
package/dist/li/peid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peid.js","names":[],"sources":["../../src/li/peid.ts"],"sourcesContent":["/** Generate a random valid Liechtenstein PEID. */\nconst generate = (): string => {\n const len = randomInt(4, 12);\n const first = String(randomInt(1, 9));\n return first + randomDigits(len - 1);\n};\n\n/**\n * PEID (Personenidentifikationsnummer).\n *\n * Liechtenstein tax code for individuals and entities.\n * Numeric code of 4 to 12 digits, with leading zeros\n * stripped during compaction.\n *\n * @see https://www.oera.li/\n */\n\nimport { clean } from \"#util/clean\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"peid.js","names":[],"sources":["../../src/li/peid.ts"],"sourcesContent":["/** Generate a random valid Liechtenstein PEID. */\nconst generate = (): string => {\n const len = randomInt(4, 12);\n const first = String(randomInt(1, 9));\n return first + randomDigits(len - 1);\n};\n\n/**\n * PEID (Personenidentifikationsnummer).\n *\n * Liechtenstein tax code for individuals and entities.\n * Numeric code of 4 to 12 digits, with leading zeros\n * stripped during compaction.\n *\n * @see https://www.oera.li/\n */\n\nimport type {\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\nconst compact = (value: string): string =>\n clean(value, \" .\").replace(/^0+/, \"\");\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n if (v.length < 4 || v.length > 12) {\n return err(\n \"INVALID_LENGTH\",\n \"Liechtenstein PEID must be 4 to 12 digits\",\n );\n }\n if (!isdigits(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"Liechtenstein PEID must contain only digits\",\n );\n }\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => compact(value);\n\n/** Liechtenstein Person Identification Number. */\nconst peid: CountryValidator<\"LI\"> = {\n name: \"Liechtenstein Person Identification Number\",\n localName: \"Personenidentifikationsnummer\",\n abbreviation: \"PEID\",\n aliases: [\"PEID\", \"Personenidentifikation\"] as const,\n candidatePattern: \"\\\\d{6}\",\n scope: \"country\",\n country: \"LI\",\n entityType: \"any\",\n lengths: [4, 5, 6, 7, 8, 9, 10, 11, 12] as const,\n sourceUrl: \"https://www.oera.li/\",\n examples: [\"1234567\"] as const,\n compact,\n format,\n validate,\n generate,\n};\n\nexport default peid;\nexport { compact, format, validate, generate };\n"],"mappings":";;;;;;AACA,MAAM,iBAAyB;CAC7B,MAAM,MAAM,UAAU,GAAG,EAAE;CAE3B,OADc,OAAO,UAAU,GAAG,CAAC,CACxB,IAAI,aAAa,MAAM,CAAC;AACrC;AAsBA,MAAM,WAAW,UACf,MAAM,OAAO,IAAI,EAAE,QAAQ,OAAO,EAAE;AAEtC,MAAM,YAAY,UAAkC;CAClD,MAAM,IAAI,QAAQ,KAAK;CACvB,IAAI,EAAE,SAAS,KAAK,EAAE,SAAS,IAC7B,OAAO,IACL,kBACA,2CACF;CAEF,IAAI,CAAC,SAAS,CAAC,GACb,OAAO,IACL,kBACA,6CACF;CAEF,OAAO;EAAE,OAAO;EAAM,SAAS;CAAE;AACnC;AAEA,MAAM,UAAU,UAA0B,QAAQ,KAAK;;AAGvD,MAAM,OAA+B;CACnC,MAAM;CACN,WAAW;CACX,cAAc;CACd,SAAS,CAAC,QAAQ,wBAAwB;CAC1C,kBAAkB;CAClB,OAAO;CACP,SAAS;CACT,YAAY;CACZ,SAAS;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAI;EAAI;CAAE;CACtC,WAAW;CACX,UAAU,CAAC,SAAS;CACpB;CACA;CACA;CACA;AACF"}
|
package/dist/lk/nic.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsedPersonId, ValidateResult
|
|
1
|
+
import { CountryValidator, ParsedPersonId, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/lk/nic.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -12,7 +12,7 @@ declare const parse: (value: string) => ParsedPersonId | null;
|
|
|
12
12
|
/** Generate a random valid Sri Lankan NIC. */
|
|
13
13
|
declare const generate: () => string;
|
|
14
14
|
/** Sri Lankan National Identity Card. */
|
|
15
|
-
declare const nic:
|
|
15
|
+
declare const nic: CountryValidator<"LK", ParsedPersonId>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { compact, nic as default, format, generate, parse, validate };
|
|
18
18
|
//# sourceMappingURL=nic.d.ts.map
|
package/dist/lk/nic.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import { clean } from "../_util/clean.js";
|
|
2
|
+
import { isValidDate } from "../_util/date.js";
|
|
2
3
|
import { randomDigits, randomInt } from "../_util/generate.js";
|
|
3
4
|
import { err } from "../_util/result.js";
|
|
4
5
|
import { isdigits } from "../_util/strings.js";
|
|
5
|
-
import { isValidDate } from "../_util/date.js";
|
|
6
6
|
//#region src/lk/nic.ts
|
|
7
|
-
/**
|
|
8
|
-
* NIC (National Identity Card, ජාතික හැඳුනුම්පත).
|
|
9
|
-
*
|
|
10
|
-
* Sri Lankan personal identity number. Two formats:
|
|
11
|
-
* Old (pre-2016): 9 digits + V or X (10 chars)
|
|
12
|
-
* New (2016+): 12 digits
|
|
13
|
-
*
|
|
14
|
-
* Both encode birth date (day-of-year), gender, a
|
|
15
|
-
* serial number, and a check digit.
|
|
16
|
-
*
|
|
17
|
-
* @see https://en.wikipedia.org/wiki/National_identification_number#Sri_Lanka
|
|
18
|
-
* @see https://drp.gov.lk/Templates/Artical%20-%20English%20new%20number.html
|
|
19
|
-
*/
|
|
20
7
|
/** Old format: 9 digits + V or X (case-insensitive). */
|
|
21
8
|
const OLD_RE = /^\d{9}[VvXx]$/;
|
|
22
9
|
/** New format: exactly 12 digits. */
|
|
@@ -133,6 +120,7 @@ const nic = {
|
|
|
133
120
|
abbreviation: "NIC",
|
|
134
121
|
aliases: ["NIC", "ජාතික හැඳුනුම්පත"],
|
|
135
122
|
candidatePattern: "\\d{9}[VXvx]|\\d{12}",
|
|
123
|
+
scope: "country",
|
|
136
124
|
country: "LK",
|
|
137
125
|
entityType: "person",
|
|
138
126
|
description: "Sri Lankan personal identity number issued to all citizens",
|
package/dist/lk/nic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nic.js","names":[],"sources":["../../src/lk/nic.ts"],"sourcesContent":["/**\n * NIC (National Identity Card, ජාතික හැඳුනුම්පත).\n *\n * Sri Lankan personal identity number. Two formats:\n * Old (pre-2016): 9 digits + V or X (10 chars)\n * New (2016+): 12 digits\n *\n * Both encode birth date (day-of-year), gender, a\n * serial number, and a check digit.\n *\n * @see https://en.wikipedia.org/wiki/National_identification_number#Sri_Lanka\n * @see https://drp.gov.lk/Templates/Artical%20-%20English%20new%20number.html\n */\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\
|
|
1
|
+
{"version":3,"file":"nic.js","names":[],"sources":["../../src/lk/nic.ts"],"sourcesContent":["/**\n * NIC (National Identity Card, ජාතික හැඳුනුම්පත).\n *\n * Sri Lankan personal identity number. Two formats:\n * Old (pre-2016): 9 digits + V or X (10 chars)\n * New (2016+): 12 digits\n *\n * Both encode birth date (day-of-year), gender, a\n * serial number, and a check digit.\n *\n * @see https://en.wikipedia.org/wiki/National_identification_number#Sri_Lanka\n * @see https://drp.gov.lk/Templates/Artical%20-%20English%20new%20number.html\n */\n\nimport type {\n ParsedPersonId,\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomDigits, randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\n/** Old format: 9 digits + V or X (case-insensitive). */\nconst OLD_RE = /^\\d{9}[VvXx]$/;\n\n/** New format: exactly 12 digits. */\nconst NEW_RE = /^\\d{12}$/;\n\nconst compact = (value: string): string =>\n clean(value, \" -\").toUpperCase();\n\n/**\n * Convert an old-format NIC to the 12-digit new\n * format for uniform validation.\n *\n * Old: YY DDD SSS C V/X (10 chars)\n * New: 19YY DDD 0SSS C (12 digits)\n */\nconst toNewFormat = (v: string): string => {\n const yy = v.slice(0, 2);\n const ddd = v.slice(2, 5);\n const sss = v.slice(5, 8);\n const check = v[8];\n return `19${yy}${ddd}0${sss}${check}`;\n};\n\n/**\n * Checksum weights for the first 11 digits.\n * Algorithm: weighted sum mod 11, then mod 10\n * if >= 10.\n */\nconst CHECK_WEIGHTS = [\n 8, 4, 3, 2, 7, 6, 5, 7, 4, 3, 2,\n] as const;\n\nconst checkDigit = (digits: string): number => {\n let sum = 0;\n for (let i = 0; i < 11; i++) {\n sum +=\n (CHECK_WEIGHTS[i] ?? 0) * Number(digits.charAt(i));\n }\n const d = 11 - (sum % 11);\n return d > 9 ? d % 10 : d;\n};\n\n/**\n * Resolve birth date and gender from the 12-digit\n * normalised form (YYYY DDD ...).\n *\n * Day-of-year encoding:\n * Male: 1–366\n * Female: 501–866 (subtract 500)\n */\nconst resolveBirthInfo = (\n v: string,\n): {\n year: number;\n month: number;\n day: number;\n gender: \"male\" | \"female\";\n} | null => {\n const year = Number(v.slice(0, 4));\n let days = Number(v.slice(4, 7));\n\n const gender: \"male\" | \"female\" =\n days > 500 ? \"female\" : \"male\";\n if (days > 500) days -= 500;\n\n if (days < 1 || days > 366) return null;\n\n // Convert day-of-year to month/day via Date\n const d = new Date(year, 0, days);\n const month = d.getMonth() + 1;\n const dayOfMonth = d.getDate();\n\n if (!isValidDate(year, month, dayOfMonth)) {\n return null;\n }\n\n // Guard against day 366 in non-leap years\n if (d.getFullYear() !== year) return null;\n\n return { year, month, day: dayOfMonth, gender };\n};\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n const isOld = OLD_RE.test(v);\n const isNew = NEW_RE.test(v);\n\n if (!isOld && !isNew) {\n if (v.length !== 10 && v.length !== 12) {\n return err(\n \"INVALID_LENGTH\",\n \"NIC must be 10 (old) or 12 (new) characters\",\n );\n }\n return err(\n \"INVALID_FORMAT\",\n \"NIC must be 9 digits + V/X (old) or\" +\n \" 12 digits (new)\",\n );\n }\n\n const normalized = isOld ? toNewFormat(v) : v;\n\n if (!isdigits(normalized)) {\n return err(\n \"INVALID_FORMAT\",\n \"NIC contains invalid characters\",\n );\n }\n\n if (resolveBirthInfo(normalized) === null) {\n return err(\n \"INVALID_COMPONENT\",\n \"NIC contains an invalid date of birth\",\n );\n }\n\n const expected = checkDigit(normalized.slice(0, 11));\n if (expected !== Number(normalized[11])) {\n return err(\n \"INVALID_CHECKSUM\",\n \"NIC check digit does not match\",\n );\n }\n\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => {\n const v = compact(value);\n // Old format: YYDDDSSSXV → no standard separator\n // New format: YYYYDDDSSSSC → no standard separator\n return v;\n};\n\n/**\n * Extract birth date and gender from an NIC.\n * Returns null if the value is not valid.\n */\nconst parse = (value: string): ParsedPersonId | null => {\n const result = validate(value);\n if (!result.valid) return null;\n\n const v = result.compact;\n const isOld = OLD_RE.test(v);\n const normalized = isOld ? toNewFormat(v) : v;\n\n const info = resolveBirthInfo(normalized);\n if (info === null) return null;\n\n return {\n birthDate: new Date(\n info.year,\n info.month - 1,\n info.day,\n ),\n gender: info.gender,\n };\n};\n\n/** Generate a random valid Sri Lankan NIC. */\nconst generate = (): string => {\n const year = randomInt(1950, 2024);\n const start = new Date(year, 0, 1);\n const end = new Date(year, 11, 31);\n const maxDay =\n Math.round(\n (end.getTime() - start.getTime()) / 86_400_000,\n ) + 1;\n const dayOfYear = randomInt(1, maxDay);\n const genderOffset = Math.random() < 0.5 ? 0 : 500;\n const ddd = String(dayOfYear + genderOffset).padStart(\n 3,\n \"0\",\n );\n const body = `${year}${ddd}0${randomDigits(3)}`;\n return `${body}${String(checkDigit(body))}`;\n};\n\n/** Sri Lankan National Identity Card. */\nconst nic: CountryValidator<\"LK\", ParsedPersonId> = {\n name: \"National Identity Card\",\n localName: \"ජාතික හැඳුනුම්පත\",\n abbreviation: \"NIC\",\n aliases: [\"NIC\", \"ජාතික හැඳුනුම්පත\"] as const,\n candidatePattern: \"\\\\d{9}[VXvx]|\\\\d{12}\",\n scope: \"country\",\n country: \"LK\",\n entityType: \"person\",\n description:\n \"Sri Lankan personal identity number issued to\" +\n \" all citizens\",\n sourceUrl:\n \"https://en.wikipedia.org/wiki/\" +\n \"National_identification_number#Sri_Lanka\",\n lengths: [10, 12] as const,\n examples: [\"197819202757\", \"862348753V\"] as const,\n compact,\n format,\n parse,\n validate,\n generate,\n};\n\nexport default nic;\nexport { compact, format, generate, parse, validate };\n"],"mappings":";;;;;;;AA2BA,MAAM,SAAS;;AAGf,MAAM,SAAS;AAEf,MAAM,WAAW,UACf,MAAM,OAAO,IAAI,EAAE,YAAY;;;;;;;;AASjC,MAAM,eAAe,MAAsB;CAKzC,OAAO,KAJI,EAAE,MAAM,GAAG,CAIT,IAHD,EAAE,MAAM,GAAG,CAGJ,EAAE,GAFT,EAAE,MAAM,GAAG,CAEG,IADZ,EAAE;AAElB;;;;;;AAOA,MAAM,gBAAgB;CACpB;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAChC;AAEA,MAAM,cAAc,WAA2B;CAC7C,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KACtB,QACG,cAAc,MAAM,KAAK,OAAO,OAAO,OAAO,CAAC,CAAC;CAErD,MAAM,IAAI,KAAM,MAAM;CACtB,OAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;;;;;;;;;AAUA,MAAM,oBACJ,MAMU;CACV,MAAM,OAAO,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC;CACjC,IAAI,OAAO,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC;CAE/B,MAAM,SACJ,OAAO,MAAM,WAAW;CAC1B,IAAI,OAAO,KAAK,QAAQ;CAExB,IAAI,OAAO,KAAK,OAAO,KAAK,OAAO;CAGnC,MAAM,IAAI,IAAI,KAAK,MAAM,GAAG,IAAI;CAChC,MAAM,QAAQ,EAAE,SAAS,IAAI;CAC7B,MAAM,aAAa,EAAE,QAAQ;CAE7B,IAAI,CAAC,YAAY,MAAM,OAAO,U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,IAAI,EAAE;CAKjC,MAAM,YAAY,UAAU,GAH1B,KAAK,OACF,IAAI,QAAQ,IAAI,MAAM,QAAQ,KAAK,KACtC,IAAI,CAC+B;CAMrC,MAAM,OAAO,GAAG,OAJJ,OAAO,aADE,KAAK,OAAO,IAAI,KAAM,IAAI,IACJ,EAAE,SAC3C,GACA,GAEuB,EAAE,GAAG,aAAa,CAAC;CAC5C,OAAO,GAAG,OAAO,OAAO,WAAW,IAAI,CAAC;AAC1C;;AAGA,MAAM,MAA8C;CAClD,MAAM;CACN,WAAW;CACX,cAAc;CACd,SAAS,CAAC,OAAO,kBAAkB;CACnC,kBAAkB;CAClB,OAAO;CACP,SAAS;CACT,YAAY;CACZ,aACE;CAEF,WACE;CAEF,SAAS,CAAC,IAAI,EAAE;CAChB,UAAU,CAAC,gBAAgB,YAAY;CACvC;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/lt/asmens.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CountryValidator, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/lt/asmens.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -7,7 +7,7 @@ declare const format: (value: string) => string;
|
|
|
7
7
|
/** Generate a random valid Lithuanian personal code. */
|
|
8
8
|
declare const generate: () => string;
|
|
9
9
|
/** Lithuanian Personal Code. */
|
|
10
|
-
declare const asmens:
|
|
10
|
+
declare const asmens: CountryValidator<"LT">;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { compact, asmens as default, format, generate, validate };
|
|
13
13
|
//# sourceMappingURL=asmens.d.ts.map
|
package/dist/lt/asmens.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clean } from "../_util/clean.js";
|
|
2
|
+
import { isValidDate } from "../_util/date.js";
|
|
2
3
|
import { randomInt } from "../_util/generate.js";
|
|
3
4
|
import { err } from "../_util/result.js";
|
|
4
5
|
import { isdigits } from "../_util/strings.js";
|
|
5
|
-
import { isValidDate } from "../_util/date.js";
|
|
6
6
|
import { twoPassCheck } from "../ee/ik.js";
|
|
7
7
|
//#region src/lt/asmens.ts
|
|
8
8
|
/**
|
|
@@ -66,6 +66,7 @@ const asmens = {
|
|
|
66
66
|
abbreviation: "AK",
|
|
67
67
|
aliases: ["asmens kodas", "AK"],
|
|
68
68
|
candidatePattern: "[3-6]\\d{10}",
|
|
69
|
+
scope: "country",
|
|
69
70
|
country: "LT",
|
|
70
71
|
entityType: "person",
|
|
71
72
|
sourceUrl: "https://www.registrucentras.lt/",
|
package/dist/lt/asmens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asmens.js","names":[],"sources":["../../src/lt/asmens.ts"],"sourcesContent":["/**\n * Asmens kodas (Personal Code).\n *\n * Lithuanian personal identification number. 11 digits\n * with the same structure as the Estonian Isikukood:\n * gender/century digit, YYMMDD, 3-digit serial, and\n * a two-pass weighted checksum.\n *\n * @see https://www.oecd.org/content/dam/oecd/en/topics/policy-issue-focus/aeoi/lithuania-tin.pdf\n * @see https://www.registrucentras.lt/\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"asmens.js","names":[],"sources":["../../src/lt/asmens.ts"],"sourcesContent":["/**\n * Asmens kodas (Personal Code).\n *\n * Lithuanian personal identification number. 11 digits\n * with the same structure as the Estonian Isikukood:\n * gender/century digit, YYMMDD, 3-digit serial, and\n * a two-pass weighted checksum.\n *\n * @see https://www.oecd.org/content/dam/oecd/en/topics/policy-issue-focus/aeoi/lithuania-tin.pdf\n * @see https://www.registrucentras.lt/\n */\n\nimport { twoPassCheck } from \"../ee/ik\";\nimport type {\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { isValidDate } from \"#util/date\";\nimport { randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\nimport { isdigits } from \"#util/strings\";\n\nconst compact = (value: string): string =>\n clean(value, \" -\");\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n if (v.length !== 11) {\n return err(\n \"INVALID_LENGTH\",\n \"Asmens kodas must be exactly 11 digits\",\n );\n }\n if (!isdigits(v)) {\n return err(\n \"INVALID_FORMAT\",\n \"Asmens kodas must contain only digits\",\n );\n }\n\n const g = Number(v[0]);\n if (g < 1 || g > 9) {\n return err(\n \"INVALID_COMPONENT\",\n \"Asmens kodas gender/century digit is invalid\",\n );\n }\n\n // Digit 9 indicates a special case where the birth\n // date is not encoded; skip date validation.\n if (g !== 9) {\n const centuryMap: Record<number, number> = {\n 1: 1800,\n 2: 1800,\n 3: 1900,\n 4: 1900,\n 5: 2000,\n 6: 2000,\n 7: 2100,\n 8: 2100,\n };\n const century = centuryMap[g] ?? 1900;\n const yy = Number(v.slice(1, 3));\n const mm = Number(v.slice(3, 5));\n const dd = Number(v.slice(5, 7));\n const year = century + yy;\n\n if (!isValidDate(year, mm, dd)) {\n return err(\n \"INVALID_COMPONENT\",\n \"Asmens kodas contains an invalid date\",\n );\n }\n }\n\n const check = twoPassCheck(v.slice(0, 10));\n if (check !== Number(v[10])) {\n return err(\n \"INVALID_CHECKSUM\",\n \"Asmens kodas check digit does not match\",\n );\n }\n\n return { valid: true, compact: v };\n};\n\nconst format = (value: string): string => compact(value);\n\n/** Generate a random valid Lithuanian personal code. */\nconst generate = (): string => {\n for (;;) {\n const g = String(randomInt(3, 6));\n const yy = String(randomInt(0, 99)).padStart(2, \"0\");\n const mm = String(randomInt(1, 12)).padStart(2, \"0\");\n const dd = String(randomInt(1, 28)).padStart(2, \"0\");\n const s = String(randomInt(0, 999)).padStart(3, \"0\");\n const payload = g + yy + mm + dd + s;\n const c = payload + String(twoPassCheck(payload));\n if (validate(c).valid) return c;\n }\n};\n\n/** Lithuanian Personal Code. */\nconst asmens: CountryValidator<\"LT\"> = {\n name: \"Lithuanian Personal ID\",\n localName: \"Asmens kodas\",\n abbreviation: \"AK\",\n aliases: [\"asmens kodas\", \"AK\"] as const,\n candidatePattern: \"[3-6]\\\\d{10}\",\n scope: \"country\",\n country: \"LT\",\n entityType: \"person\",\n sourceUrl: \"https://www.registrucentras.lt/\",\n examples: [\"33309240064\"] as const,\n compact,\n format,\n validate,\n generate,\n};\n\nexport default asmens;\nexport { compact, format, validate, generate };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,MAAM,WAAW,UACf,MAAM,OAAO,IAAI;AAEnB,MAAM,YAAY,UAAkC;CAClD,MAAM,IAAI,QAAQ,KAAK;CACvB,IAAI,EAAE,WAAW,IACf,OAAO,IACL,kBACA,wCACF;CAEF,IAAI,CAAC,SAAS,CAAC,GACb,OAAO,IACL,kBACA,uCACF;CAGF,MAAM,IAAI,OAAO,EAAE,EAAE;CACrB,IAAI,IAAI,KAAK,IAAI,GACf,OAAO,IACL,qBACA,8CACF;CAKF,IAAI,MAAM,GAAG;EAWX,MAAM,UAAU;GATd,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;EAEoB,EAAE,MAAM;EACjC,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC;EAC/B,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC;EAC/B,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC;EAG/B,IAAI,CAAC,YAFQ,UAAU,IAEA,IAAI,EAAE,GAC3B,OAAO,IACL,qBACA,uCACF;CAEJ;CAGA,IADc,aAAa,EAAE,MAAM,GAAG,EAAE,CAChC,MAAM,OAAO,EAAE,GAAG,GACxB,OAAO,IACL,oBACA,yCACF;CAGF,OAAO;EAAE,OAAO;EAAM,SAAS;CAAE;AACnC;AAEA,MAAM,UAAU,UAA0B,QAAQ,KAAK;;AAGvD,MAAM,iBAAyB;CAC7B,SAAS;EACP,MAAM,IAAI,OAAO,UAAU,GAAG,CAAC,CAAC;EAChC,MAAM,KAAK,OAAO,UAAU,GAAG,EAAE,CAAC,EAAE,SAAS,GAAG,GAAG;EACnD,MAAM,KAAK,OAAO,UAAU,GAAG,EAAE,CAAC,EAAE,SAAS,GAAG,GAAG;EACnD,MAAM,KAAK,OAAO,UAAU,GAAG,EAAE,CAAC,EAAE,SAAS,GAAG,GAAG;EACnD,MAAM,IAAI,OAAO,UAAU,GAAG,GAAG,CAAC,EAAE,SAAS,GAAG,GAAG;EACnD,MAAM,UAAU,IAAI,KAAK,KAAK,KAAK;EACnC,MAAM,IAAI,UAAU,OAAO,aAAa,OAAO,CAAC;EAChD,IAAI,SAAS,CAAC,EAAE,OAAO,OAAO;CAChC;AACF;;AAGA,MAAM,SAAiC;CACrC,MAAM;CACN,WAAW;CACX,cAAc;CACd,SAAS,CAAC,gBAAgB,IAAI;CAC9B,kBAAkB;CAClB,OAAO;CACP,SAAS;CACT,YAAY;CACZ,WAAW;CACX,UAAU,CAAC,aAAa;CACxB;CACA;CACA;CACA;AACF"}
|
package/dist/lt/vat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CountryValidator, ValidateResult } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/lt/vat.d.ts
|
|
4
4
|
declare const compact: (value: string) => string;
|
|
@@ -7,7 +7,7 @@ declare const format: (value: string) => string;
|
|
|
7
7
|
/** Generate a random valid Lithuanian VAT number. */
|
|
8
8
|
declare const generate: () => string;
|
|
9
9
|
/** Lithuanian VAT Number. */
|
|
10
|
-
declare const vat:
|
|
10
|
+
declare const vat: CountryValidator<"LT">;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { compact, vat as default, format, generate, validate };
|
|
13
13
|
//# sourceMappingURL=vat.d.ts.map
|
package/dist/lt/vat.js
CHANGED
|
@@ -3,16 +3,6 @@ import { randomDigits } from "../_util/generate.js";
|
|
|
3
3
|
import { err } from "../_util/result.js";
|
|
4
4
|
import { isdigits } from "../_util/strings.js";
|
|
5
5
|
//#region src/lt/vat.ts
|
|
6
|
-
/**
|
|
7
|
-
* PVM kodas (Lithuanian VAT number).
|
|
8
|
-
*
|
|
9
|
-
* 9 or 12 digits. 9-digit: d[7] must be 1.
|
|
10
|
-
* 12-digit: d[10] must be 1. Weighted checksum
|
|
11
|
-
* with fallback weights.
|
|
12
|
-
*
|
|
13
|
-
* @see https://www.vatify.eu/lithuania-vat-number.html
|
|
14
|
-
* @see https://www.vmi.lt/
|
|
15
|
-
*/
|
|
16
6
|
const compact = (value) => {
|
|
17
7
|
let v = clean(value, " -/.");
|
|
18
8
|
if (v.startsWith("LT") || v.startsWith("lt")) v = v.slice(2);
|
|
@@ -57,9 +47,11 @@ const vat = {
|
|
|
57
47
|
abbreviation: "PVM kodas",
|
|
58
48
|
aliases: ["PVM mokėtojo kodas", "PVM"],
|
|
59
49
|
candidatePattern: "LT\\d{9,12}",
|
|
50
|
+
scope: "country",
|
|
60
51
|
country: "LT",
|
|
61
52
|
entityType: "any",
|
|
62
53
|
sourceUrl: "https://www.vmi.lt/",
|
|
54
|
+
lengths: [9, 12],
|
|
63
55
|
examples: ["119511515", "100001919017"],
|
|
64
56
|
compact,
|
|
65
57
|
format,
|