stdnum 1.10.0 → 1.10.2
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 -0
- package/lib/cjs/in/gstin.js +3 -3
- package/lib/cjs/no/fodselsnummer.js +2 -2
- package/lib/cjs/tw/natid.js +8 -5
- package/lib/cjs/tw/ui.js +8 -5
- package/lib/esm/in/gstin.js +3 -3
- package/lib/esm/no/fodselsnummer.js +2 -2
- package/lib/esm/tw/natid.js +8 -5
- package/lib/esm/tw/ui.js +8 -5
- package/package.json +5 -2
- package/src/ad/index.ts +1 -0
- package/src/ad/nrt.spec.ts +36 -0
- package/src/ad/nrt.ts +87 -0
- package/src/al/index.ts +1 -0
- package/src/al/nipt.spec.ts +43 -0
- package/src/al/nipt.ts +111 -0
- package/src/ar/cbu.spec.ts +28 -0
- package/src/ar/cbu.ts +96 -0
- package/src/ar/cuit.spec.ts +28 -0
- package/src/ar/cuit.ts +102 -0
- package/src/ar/dni.spec.ts +22 -0
- package/src/ar/dni.ts +72 -0
- package/src/ar/index.ts +3 -0
- package/src/at/businessid.spec.ts +34 -0
- package/src/at/businessid.ts +73 -0
- package/src/at/index.ts +4 -0
- package/src/at/tin.spec.ts +173 -0
- package/src/at/tin.ts +140 -0
- package/src/at/uid.spec.ts +44 -0
- package/src/at/uid.ts +84 -0
- package/src/at/vnr.spec.ts +38 -0
- package/src/at/vnr.ts +84 -0
- package/src/au/abn.spec.ts +28 -0
- package/src/au/abn.ts +78 -0
- package/src/au/acn.spec.ts +34 -0
- package/src/au/acn.ts +76 -0
- package/src/au/index.ts +3 -0
- package/src/au/tfn.spec.ts +28 -0
- package/src/au/tfn.ts +79 -0
- package/src/az/index.ts +2 -0
- package/src/az/pin.spec.ts +16 -0
- package/src/az/pin.ts +61 -0
- package/src/az/tin.spec.ts +28 -0
- package/src/az/tin.ts +64 -0
- package/src/ba/index.ts +1 -0
- package/src/ba/jmbg.spec.ts +28 -0
- package/src/ba/jmbg.ts +85 -0
- package/src/be/bis.spec.ts +184 -0
- package/src/be/bis.ts +85 -0
- package/src/be/index.ts +4 -0
- package/src/be/insz.spec.ts +51 -0
- package/src/be/insz.ts +55 -0
- package/src/be/nn.spec.ts +117 -0
- package/src/be/nn.ts +77 -0
- package/src/be/personIdentifierHelpers.spec.ts +254 -0
- package/src/be/personIdentifierHelpers.ts +130 -0
- package/src/be/vat.spec.ts +46 -0
- package/src/be/vat.ts +84 -0
- package/src/bg/egn.spec.ts +28 -0
- package/src/bg/egn.ts +75 -0
- package/src/bg/index.ts +3 -0
- package/src/bg/pnf.spec.ts +28 -0
- package/src/bg/pnf.ts +73 -0
- package/src/bg/vat.spec.ts +34 -0
- package/src/bg/vat.ts +120 -0
- package/src/br/cnpj.spec.ts +34 -0
- package/src/br/cnpj.ts +89 -0
- package/src/br/cpf.spec.ts +34 -0
- package/src/br/cpf.ts +87 -0
- package/src/br/index.ts +2 -0
- package/src/by/index.ts +1 -0
- package/src/by/unp.spec.ts +34 -0
- package/src/by/unp.ts +108 -0
- package/src/bz/index.ts +1 -0
- package/src/bz/tin.spec.ts +28 -0
- package/src/bz/tin.ts +67 -0
- package/src/ca/bn.spec.ts +40 -0
- package/src/ca/bn.ts +88 -0
- package/src/ca/gst.spec.ts +34 -0
- package/src/ca/gst.ts +70 -0
- package/src/ca/index.ts +5 -0
- package/src/ca/pst.spec.ts +28 -0
- package/src/ca/pst.ts +71 -0
- package/src/ca/qst.spec.ts +47 -0
- package/src/ca/qst.ts +88 -0
- package/src/ca/sin.spec.ts +34 -0
- package/src/ca/sin.ts +72 -0
- package/src/ch/index.ts +3 -0
- package/src/ch/ssn.spec.ts +50 -0
- package/src/ch/ssn.ts +74 -0
- package/src/ch/uid.spec.ts +34 -0
- package/src/ch/uid.ts +82 -0
- package/src/ch/vat.spec.ts +28 -0
- package/src/ch/vat.ts +83 -0
- package/src/cl/index.ts +2 -0
- package/src/cl/run.ts +13 -0
- package/src/cl/rut.spec.ts +50 -0
- package/src/cl/rut.ts +97 -0
- package/src/cn/index.ts +2 -0
- package/src/cn/ric.spec.ts +34 -0
- package/src/cn/ric.ts +86 -0
- package/src/cn/uscc.spec.ts +34 -0
- package/src/cn/uscc.ts +110 -0
- package/src/co/index.ts +1 -0
- package/src/co/nit.spec.ts +40 -0
- package/src/co/nit.ts +85 -0
- package/src/cr/cpf.spec.ts +34 -0
- package/src/cr/cpf.ts +93 -0
- package/src/cr/cpj.spec.ts +28 -0
- package/src/cr/cpj.ts +111 -0
- package/src/cr/cr.spec.ts +28 -0
- package/src/cr/cr.ts +75 -0
- package/src/cr/index.ts +3 -0
- package/src/cu/index.ts +1 -0
- package/src/cu/ni.spec.ts +34 -0
- package/src/cu/ni.ts +74 -0
- package/src/cy/index.ts +1 -0
- package/src/cy/vat.spec.ts +28 -0
- package/src/cy/vat.ts +98 -0
- package/src/cz/dic.spec.ts +28 -0
- package/src/cz/dic.ts +127 -0
- package/src/cz/index.ts +2 -0
- package/src/cz/rc.spec.ts +44 -0
- package/src/cz/rc.ts +95 -0
- package/src/de/idnr.spec.ts +34 -0
- package/src/de/idnr.ts +91 -0
- package/src/de/index.ts +6 -0
- package/src/de/passport.spec.ts +31 -0
- package/src/de/passport.ts +86 -0
- package/src/de/pwnr.spec.ts +62 -0
- package/src/de/pwnr.ts +190 -0
- package/src/de/stnr.spec.ts +85 -0
- package/src/de/stnr.ts +193 -0
- package/src/de/svnr.spec.ts +56 -0
- package/src/de/svnr.ts +158 -0
- package/src/de/vat.spec.ts +28 -0
- package/src/de/vat.ts +74 -0
- package/src/dk/cpr.spec.ts +34 -0
- package/src/dk/cpr.ts +129 -0
- package/src/dk/cvr.spec.ts +28 -0
- package/src/dk/cvr.ts +81 -0
- package/src/dk/index.ts +2 -0
- package/src/do/cedula.spec.ts +34 -0
- package/src/do/cedula.ts +67 -0
- package/src/do/index.ts +3 -0
- package/src/do/ncf.spec.ts +34 -0
- package/src/do/ncf.ts +133 -0
- package/src/do/rnc.spec.ts +40 -0
- package/src/do/rnc.ts +74 -0
- package/src/dz/index.ts +1 -0
- package/src/dz/nif.spec.ts +39 -0
- package/src/dz/nif.ts +80 -0
- package/src/ec/ci.spec.ts +28 -0
- package/src/ec/ci.ts +92 -0
- package/src/ec/index.ts +2 -0
- package/src/ec/ruc.spec.ts +37 -0
- package/src/ec/ruc.ts +117 -0
- package/src/ee/ik.spec.ts +28 -0
- package/src/ee/ik.ts +114 -0
- package/src/ee/index.ts +3 -0
- package/src/ee/kmkr.spec.ts +28 -0
- package/src/ee/kmkr.ts +76 -0
- package/src/ee/registrikood.spec.ts +28 -0
- package/src/ee/registrikood.ts +80 -0
- package/src/eg/index.ts +1 -0
- package/src/eg/tn.spec.ts +44 -0
- package/src/eg/tn.ts +96 -0
- package/src/es/cif.spec.ts +43 -0
- package/src/es/cif.ts +84 -0
- package/src/es/dni.spec.ts +28 -0
- package/src/es/dni.ts +83 -0
- package/src/es/index.ts +5 -0
- package/src/es/nie.spec.ts +28 -0
- package/src/es/nie.ts +79 -0
- package/src/es/nif.spec.ts +52 -0
- package/src/es/nif.ts +95 -0
- package/src/es/nss.spec.ts +28 -0
- package/src/es/nss.ts +132 -0
- package/src/exceptions.ts +66 -0
- package/src/fi/alv.spec.ts +28 -0
- package/src/fi/alv.ts +76 -0
- package/src/fi/hetu.spec.ts +37 -0
- package/src/fi/hetu.ts +108 -0
- package/src/fi/index.ts +3 -0
- package/src/fi/ytunnus.spec.ts +28 -0
- package/src/fi/ytunnus.ts +49 -0
- package/src/fo/index.ts +1 -0
- package/src/fo/vn.spec.ts +34 -0
- package/src/fo/vn.ts +71 -0
- package/src/fr/index.ts +5 -0
- package/src/fr/nif.spec.ts +34 -0
- package/src/fr/nif.ts +82 -0
- package/src/fr/nir.spec.ts +36 -0
- package/src/fr/nir.ts +98 -0
- package/src/fr/siren.spec.ts +28 -0
- package/src/fr/siren.ts +68 -0
- package/src/fr/siret.spec.ts +38 -0
- package/src/fr/siret.ts +79 -0
- package/src/fr/tva.spec.ts +40 -0
- package/src/fr/tva.ts +125 -0
- package/src/gb/index.ts +3 -0
- package/src/gb/nino-prefixes.ts +245 -0
- package/src/gb/nino.spec.ts +80 -0
- package/src/gb/nino.ts +80 -0
- package/src/gb/utr.spec.ts +28 -0
- package/src/gb/utr.ts +76 -0
- package/src/gb/vat.spec.ts +40 -0
- package/src/gb/vat.ts +112 -0
- package/src/gen/ean.spec.ts +34 -0
- package/src/gen/ean.ts +71 -0
- package/src/gen/index.ts +1 -0
- package/src/gh/index.ts +1 -0
- package/src/gh/tin.spec.ts +42 -0
- package/src/gh/tin.ts +93 -0
- package/src/gn/index.ts +1 -0
- package/src/gn/nifp.spec.ts +40 -0
- package/src/gn/nifp.ts +72 -0
- package/src/gr/amka.spec.ts +28 -0
- package/src/gr/amka.ts +76 -0
- package/src/gr/index.ts +2 -0
- package/src/gr/vat.spec.ts +34 -0
- package/src/gr/vat.ts +84 -0
- package/src/gt/cui.spec.ts +34 -0
- package/src/gt/cui.ts +110 -0
- package/src/gt/index.ts +2 -0
- package/src/gt/nit.spec.ts +34 -0
- package/src/gt/nit.ts +86 -0
- package/src/hk/hkid.spec.ts +52 -0
- package/src/hk/hkid.ts +90 -0
- package/src/hk/index.ts +1 -0
- package/src/hr/index.ts +1 -0
- package/src/hr/oib.spec.ts +28 -0
- package/src/hr/oib.ts +67 -0
- package/src/hu/anum.spec.ts +28 -0
- package/src/hu/anum.ts +71 -0
- package/src/hu/index.ts +1 -0
- package/src/id/index.ts +1 -0
- package/src/id/npwp.spec.ts +34 -0
- package/src/id/npwp.ts +116 -0
- package/src/ie/index.ts +2 -0
- package/src/ie/pps.spec.ts +58 -0
- package/src/ie/pps.ts +81 -0
- package/src/ie/vat.spec.ts +40 -0
- package/src/ie/vat.ts +99 -0
- package/src/il/hp.spec.ts +38 -0
- package/src/il/hp.ts +75 -0
- package/src/il/idnr.spec.ts +28 -0
- package/src/il/idnr.ts +70 -0
- package/src/il/index.ts +2 -0
- package/src/in/aadhaar.spec.ts +40 -0
- package/src/in/aadhaar.ts +85 -0
- package/src/in/epic.spec.ts +34 -0
- package/src/in/epic.ts +85 -0
- package/src/in/gstin.spec.ts +34 -0
- package/src/in/gstin.ts +156 -0
- package/src/in/index.ts +4 -0
- package/src/in/pan.spec.ts +40 -0
- package/src/in/pan.ts +93 -0
- package/src/index.ts +404 -0
- package/src/is/index.ts +2 -0
- package/src/is/kennitala.spec.ts +46 -0
- package/src/is/kennitala.ts +80 -0
- package/src/is/vsk.spec.ts +22 -0
- package/src/is/vsk.ts +60 -0
- package/src/it/aic.spec.ts +40 -0
- package/src/it/aic.ts +97 -0
- package/src/it/codicefiscale.spec.ts +28 -0
- package/src/it/codicefiscale.ts +167 -0
- package/src/it/index.ts +3 -0
- package/src/it/iva.spec.ts +28 -0
- package/src/it/iva.ts +65 -0
- package/src/jp/cn.spec.ts +28 -0
- package/src/jp/cn.ts +77 -0
- package/src/jp/index.ts +1 -0
- package/src/ke/index.ts +1 -0
- package/src/ke/pin.spec.ts +34 -0
- package/src/ke/pin.ts +77 -0
- package/src/kr/brn.spec.ts +28 -0
- package/src/kr/brn.ts +91 -0
- package/src/kr/index.ts +2 -0
- package/src/kr/rrn.spec.ts +34 -0
- package/src/kr/rrn.ts +104 -0
- package/src/li/index.ts +1 -0
- package/src/li/peid.spec.ts +22 -0
- package/src/li/peid.ts +71 -0
- package/src/lt/asmens.spec.ts +28 -0
- package/src/lt/asmens.ts +73 -0
- package/src/lt/index.ts +2 -0
- package/src/lt/pvm.spec.ts +34 -0
- package/src/lt/pvm.ts +75 -0
- package/src/lu/index.ts +1 -0
- package/src/lu/tva.spec.ts +28 -0
- package/src/lu/tva.ts +70 -0
- package/src/lv/index.ts +1 -0
- package/src/lv/pvn.spec.ts +44 -0
- package/src/lv/pvn.ts +102 -0
- package/src/ma/ice.spec.ts +39 -0
- package/src/ma/ice.ts +72 -0
- package/src/ma/ice9.spec.ts +28 -0
- package/src/ma/ice9.ts +62 -0
- package/src/ma/index.ts +2 -0
- package/src/mc/index.ts +1 -0
- package/src/mc/tva.spec.ts +28 -0
- package/src/mc/tva.ts +67 -0
- package/src/md/idno.spec.ts +28 -0
- package/src/md/idno.ts +78 -0
- package/src/md/index.ts +1 -0
- package/src/me/index.ts +2 -0
- package/src/me/jmbg.ts +17 -0
- package/src/me/pib.spec.ts +158 -0
- package/src/me/pib.ts +77 -0
- package/src/mk/edb.spec.ts +50 -0
- package/src/mk/edb.ts +88 -0
- package/src/mk/index.ts +2 -0
- package/src/mk/jmbg.ts +17 -0
- package/src/mt/index.ts +1 -0
- package/src/mt/vat.spec.ts +28 -0
- package/src/mt/vat.ts +69 -0
- package/src/mu/index.ts +1 -0
- package/src/mu/nid.spec.ts +34 -0
- package/src/mu/nid.ts +89 -0
- package/src/mx/banks.ts +658 -0
- package/src/mx/clabe.spec.ts +68 -0
- package/src/mx/clabe.ts +105 -0
- package/src/mx/curp.spec.ts +28 -0
- package/src/mx/curp.ts +261 -0
- package/src/mx/index.ts +3 -0
- package/src/mx/rfc.spec.ts +69 -0
- package/src/mx/rfc.ts +193 -0
- package/src/my/index.ts +1 -0
- package/src/my/nric.spec.ts +40 -0
- package/src/my/nric.ts +91 -0
- package/src/nl/bsn.spec.ts +68 -0
- package/src/nl/bsn.ts +81 -0
- package/src/nl/btw.spec.ts +40 -0
- package/src/nl/btw.ts +95 -0
- package/src/nl/index.ts +3 -0
- package/src/nl/onderwijsnummer.spec.ts +34 -0
- package/src/nl/onderwijsnummer.ts +77 -0
- package/src/no/fodselsnummer.spec.ts +56 -0
- package/src/no/fodselsnummer.ts +118 -0
- package/src/no/index.ts +4 -0
- package/src/no/kontonr.spec.ts +34 -0
- package/src/no/kontonr.ts +84 -0
- package/src/no/mva.spec.ts +28 -0
- package/src/no/mva.ts +80 -0
- package/src/no/orgnr.spec.ts +28 -0
- package/src/no/orgnr.ts +75 -0
- package/src/nz/bank.spec.ts +28 -0
- package/src/nz/bank.ts +238 -0
- package/src/nz/index.ts +2 -0
- package/src/nz/ird.spec.ts +34 -0
- package/src/nz/ird.ts +102 -0
- package/src/pe/ce.spec.ts +46 -0
- package/src/pe/ce.ts +61 -0
- package/src/pe/cui.spec.ts +28 -0
- package/src/pe/cui.ts +85 -0
- package/src/pe/index.ts +3 -0
- package/src/pe/ruc.spec.ts +46 -0
- package/src/pe/ruc.ts +84 -0
- package/src/pk/cnic.spec.ts +34 -0
- package/src/pk/cnic.ts +97 -0
- package/src/pk/index.ts +2 -0
- package/src/pk/ntn.spec.ts +22 -0
- package/src/pk/ntn.ts +65 -0
- package/src/pl/index.ts +3 -0
- package/src/pl/nip.spec.ts +34 -0
- package/src/pl/nip.ts +74 -0
- package/src/pl/pesel.spec.ts +34 -0
- package/src/pl/pesel.ts +97 -0
- package/src/pl/regon.spec.ts +52 -0
- package/src/pl/regon.ts +88 -0
- package/src/pt/cc.spec.ts +43 -0
- package/src/pt/cc.ts +74 -0
- package/src/pt/index.ts +3 -0
- package/src/pt/nif.spec.ts +28 -0
- package/src/pt/nif.ts +78 -0
- package/src/pt/nipc.ts +27 -0
- package/src/py/cedula.spec.ts +46 -0
- package/src/py/cedula.ts +73 -0
- package/src/py/index.ts +2 -0
- package/src/py/ruc.spec.ts +40 -0
- package/src/py/ruc.ts +93 -0
- package/src/ro/cif.spec.ts +40 -0
- package/src/ro/cif.ts +62 -0
- package/src/ro/cnp.spec.ts +50 -0
- package/src/ro/cnp.ts +158 -0
- package/src/ro/cui.spec.ts +28 -0
- package/src/ro/cui.ts +83 -0
- package/src/ro/index.ts +4 -0
- package/src/ro/onrc.spec.ts +28 -0
- package/src/ro/onrc.ts +109 -0
- package/src/rs/index.ts +2 -0
- package/src/rs/jmbg.ts +16 -0
- package/src/rs/pib.spec.ts +28 -0
- package/src/rs/pib.ts +69 -0
- package/src/ru/index.ts +1 -0
- package/src/ru/inn.spec.ts +32 -0
- package/src/ru/inn.ts +106 -0
- package/src/se/index.ts +3 -0
- package/src/se/orgnr.spec.ts +28 -0
- package/src/se/orgnr.ts +68 -0
- package/src/se/personnummer.spec.ts +45 -0
- package/src/se/personnummer.ts +143 -0
- package/src/se/vat.spec.ts +28 -0
- package/src/se/vat.ts +73 -0
- package/src/sg/index.ts +1 -0
- package/src/sg/uen.spec.ts +46 -0
- package/src/sg/uen.ts +209 -0
- package/src/si/ddv.spec.ts +28 -0
- package/src/si/ddv.ts +76 -0
- package/src/si/emso.spec.ts +15 -0
- package/src/si/emso.ts +27 -0
- package/src/si/index.ts +3 -0
- package/src/si/jmbg.ts +20 -0
- package/src/sk/dph.spec.ts +28 -0
- package/src/sk/dph.ts +71 -0
- package/src/sk/index.ts +2 -0
- package/src/sk/rc.ts +12 -0
- package/src/sm/coe.spec.ts +34 -0
- package/src/sm/coe.ts +80 -0
- package/src/sm/index.ts +1 -0
- package/src/sv/index.ts +1 -0
- package/src/sv/nit.spec.ts +34 -0
- package/src/sv/nit.ts +117 -0
- package/src/th/idnr.spec.ts +41 -0
- package/src/th/idnr.ts +80 -0
- package/src/th/index.ts +3 -0
- package/src/th/moa.spec.ts +62 -0
- package/src/th/moa.ts +85 -0
- package/src/th/tin.spec.ts +77 -0
- package/src/th/tin.ts +56 -0
- package/src/tn/index.ts +1 -0
- package/src/tn/mf.spec.ts +37 -0
- package/src/tn/mf.ts +169 -0
- package/src/tr/index.ts +2 -0
- package/src/tr/tckimlik.spec.ts +40 -0
- package/src/tr/tckimlik.ts +87 -0
- package/src/tr/vkn.spec.ts +28 -0
- package/src/tr/vkn.ts +87 -0
- package/src/tw/ban.spec.ts +28 -0
- package/src/tw/ban.ts +67 -0
- package/src/tw/index.ts +5 -0
- package/src/tw/natid.spec.ts +41 -0
- package/src/tw/natid.ts +109 -0
- package/src/tw/tax_code.spec.ts +34 -0
- package/src/tw/tax_code.ts +98 -0
- package/src/tw/ubn.spec.ts +28 -0
- package/src/tw/ubn.ts +80 -0
- package/src/tw/ui.spec.ts +49 -0
- package/src/tw/ui.ts +111 -0
- package/src/types.ts +82 -0
- package/src/ua/edrpou.spec.ts +28 -0
- package/src/ua/edrpou.ts +88 -0
- package/src/ua/index.ts +2 -0
- package/src/ua/rntrc.spec.ts +28 -0
- package/src/ua/rntrc.ts +77 -0
- package/src/us/ein.spec.ts +28 -0
- package/src/us/ein.ts +179 -0
- package/src/us/index.ts +2 -0
- package/src/us/ssn.spec.ts +28 -0
- package/src/us/ssn.ts +117 -0
- package/src/util/checksum.spec.ts +70 -0
- package/src/util/checksum.ts +258 -0
- package/src/util/index.ts +13 -0
- package/src/util/isValidDate.spec.ts +49 -0
- package/src/util/isValidDate.ts +87 -0
- package/src/util/iso7064.spec.ts +17 -0
- package/src/util/iso7064.ts +8 -0
- package/src/util/pymod.ts +8 -0
- package/src/util/strings/char.ts +18 -0
- package/src/util/strings/clean.spec.ts +15 -0
- package/src/util/strings/clean.ts +305 -0
- package/src/util/strings/format.ts +18 -0
- package/src/util/strings/index.ts +5 -0
- package/src/util/strings/reverseString.ts +3 -0
- package/src/util/strings/splitAt.spec.ts +15 -0
- package/src/util/strings/splitAt.ts +16 -0
- package/src/uy/cedula.spec.ts +28 -0
- package/src/uy/cedula.ts +74 -0
- package/src/uy/index.ts +3 -0
- package/src/uy/nie.spec.ts +28 -0
- package/src/uy/nie.ts +84 -0
- package/src/uy/rut.spec.ts +34 -0
- package/src/uy/rut.ts +99 -0
- package/src/ve/index.ts +1 -0
- package/src/ve/rif.spec.ts +38 -0
- package/src/ve/rif.ts +92 -0
- package/src/vn/index.ts +1 -0
- package/src/vn/mst.spec.ts +40 -0
- package/src/vn/mst.ts +100 -0
- package/src/za/idnr.spec.ts +28 -0
- package/src/za/idnr.ts +84 -0
- package/src/za/index.ts +2 -0
- package/src/za/tin.spec.ts +28 -0
- package/src/za/tin.ts +75 -0
package/src/ro/cnp.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CNP (Cod Numeric Personal, Romanian Numerical Personal Code).
|
|
3
|
+
*
|
|
4
|
+
* The CNP is a 13 digit number that includes information on the person's
|
|
5
|
+
* gender, birth date and country zone.
|
|
6
|
+
*
|
|
7
|
+
* Source:
|
|
8
|
+
* https://ro.wikipedia.org/wiki/Cod_numeric_personal
|
|
9
|
+
*
|
|
10
|
+
* PERSON
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as exceptions from '../exceptions';
|
|
14
|
+
import { isValidDateCompactYYYYMMDD, strings, weightedSum } from '../util';
|
|
15
|
+
import { Validator, ValidateReturn } from '../types';
|
|
16
|
+
|
|
17
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
18
|
+
return strings.cleanUnicode(input, ' -');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const century: Record<string, string> = {
|
|
22
|
+
'0': '19', // shouldn't happen,
|
|
23
|
+
'1': '19',
|
|
24
|
+
'2': '19',
|
|
25
|
+
'3': '18',
|
|
26
|
+
'4': '18',
|
|
27
|
+
'5': '20',
|
|
28
|
+
'6': '20',
|
|
29
|
+
'7': '19',
|
|
30
|
+
'8': '19',
|
|
31
|
+
'9': '19',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// The Romanian counties
|
|
35
|
+
const COUNTIES: Record<string, string> = {
|
|
36
|
+
'01': 'Alba',
|
|
37
|
+
'02': 'Arad',
|
|
38
|
+
'03': 'Arges',
|
|
39
|
+
'04': 'Bacau',
|
|
40
|
+
'05': 'Bihor',
|
|
41
|
+
'06': 'Bistrita-Nasaud',
|
|
42
|
+
'07': 'Botosani',
|
|
43
|
+
'08': 'Brasov',
|
|
44
|
+
'09': 'Braila',
|
|
45
|
+
'10': 'Buzau',
|
|
46
|
+
'11': 'Caras-Severin',
|
|
47
|
+
'12': 'Cluj',
|
|
48
|
+
'13': 'Constanta',
|
|
49
|
+
'14': 'Covasna',
|
|
50
|
+
'15': 'Dambovita',
|
|
51
|
+
'16': 'Dolj',
|
|
52
|
+
'17': 'Galati',
|
|
53
|
+
'18': 'Gorj',
|
|
54
|
+
'19': 'Harghita',
|
|
55
|
+
'20': 'Hunedoara',
|
|
56
|
+
'21': 'Ialomita',
|
|
57
|
+
'22': 'Iasi',
|
|
58
|
+
'23': 'Ilfov',
|
|
59
|
+
'24': 'Maramures',
|
|
60
|
+
'25': 'Mehedinti',
|
|
61
|
+
'26': 'Mures',
|
|
62
|
+
'27': 'Neamt',
|
|
63
|
+
'28': 'Olt',
|
|
64
|
+
'29': 'Prahova',
|
|
65
|
+
'30': 'Satu Mare',
|
|
66
|
+
'31': 'Salaj',
|
|
67
|
+
'32': 'Sibiu',
|
|
68
|
+
'33': 'Suceava',
|
|
69
|
+
'34': 'Teleorman',
|
|
70
|
+
'35': 'Timis',
|
|
71
|
+
'36': 'Tulcea',
|
|
72
|
+
'37': 'Vaslui',
|
|
73
|
+
'38': 'Valcea',
|
|
74
|
+
'39': 'Vrancea',
|
|
75
|
+
'40': 'Bucuresti',
|
|
76
|
+
'41': 'Bucuresti - Sector 1',
|
|
77
|
+
'42': 'Bucuresti - Sector 2',
|
|
78
|
+
'43': 'Bucuresti - Sector 3',
|
|
79
|
+
'44': 'Bucuresti - Sector 4',
|
|
80
|
+
'45': 'Bucuresti - Sector 5',
|
|
81
|
+
'46': 'Bucuresti - Sector 6',
|
|
82
|
+
'47': 'Bucuresti - Sector 7 (desfiintat)',
|
|
83
|
+
'48': 'Bucuresti - Sector 8 (desfiintat)',
|
|
84
|
+
'51': 'Calarasi',
|
|
85
|
+
'52': 'Giurgiu',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const VALID_COUNTIES = Object.keys(COUNTIES);
|
|
89
|
+
|
|
90
|
+
const impl: Validator = {
|
|
91
|
+
name: 'Romanian Numerical Personal Code',
|
|
92
|
+
localName: 'Cod Numeric Personal',
|
|
93
|
+
abbreviation: 'CNP',
|
|
94
|
+
compact(input: string): string {
|
|
95
|
+
const [value, err] = clean(input);
|
|
96
|
+
|
|
97
|
+
if (err) {
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return value;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
format(input: string): string {
|
|
105
|
+
const [value] = clean(input);
|
|
106
|
+
|
|
107
|
+
return value;
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
validate(input: string): ValidateReturn {
|
|
111
|
+
const [value, error] = clean(input);
|
|
112
|
+
|
|
113
|
+
if (error) {
|
|
114
|
+
return { isValid: false, error };
|
|
115
|
+
}
|
|
116
|
+
if (value.length !== 13) {
|
|
117
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
118
|
+
}
|
|
119
|
+
if (!strings.isdigits(value)) {
|
|
120
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (value[0] === '0') {
|
|
124
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const [first, dvalue, county] = strings.splitAt(value, 1, 7, 9);
|
|
128
|
+
|
|
129
|
+
if (!isValidDateCompactYYYYMMDD(`${century[first]}${dvalue}`, true)) {
|
|
130
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
131
|
+
}
|
|
132
|
+
if (!VALID_COUNTIES.includes(county)) {
|
|
133
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const [front, check] = strings.splitAt(value, -1);
|
|
137
|
+
const sum = weightedSum(front, {
|
|
138
|
+
weights: [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9],
|
|
139
|
+
modulus: 11,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const digit = sum === 10 ? '1' : String(sum);
|
|
143
|
+
|
|
144
|
+
if (check !== digit) {
|
|
145
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
isValid: true,
|
|
150
|
+
compact: value,
|
|
151
|
+
isIndividual: true,
|
|
152
|
+
isCompany: false,
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
158
|
+
impl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './cui';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ro/cui', () => {
|
|
5
|
+
it('format:18547290', () => {
|
|
6
|
+
const result = format('18547290');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('185 472 90');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:185 472 90', () => {
|
|
12
|
+
const result = validate('185 472 90');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('18547290');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:123456789012', () => {
|
|
18
|
+
const result = validate('123456789012');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:185 472 91', () => {
|
|
24
|
+
const result = validate('185 472 91');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/ro/cui.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CUI or CIF (Codul Unic de Înregistrare, Romanian company identifier).
|
|
3
|
+
*
|
|
4
|
+
* The CUI (Codul Unic de Înregistrare) is assigned to companies that are
|
|
5
|
+
* required to register with the Romanian Trade Register. The CIF (Codul de
|
|
6
|
+
* identificare fiscală) is identical but assigned to entities that have no such
|
|
7
|
+
* requirement. The names seem to be used interchangeably and some sources
|
|
8
|
+
* suggest that CIF is the new name for CUI.
|
|
9
|
+
*
|
|
10
|
+
* This number can change under some conditions. The number can be prefixed with
|
|
11
|
+
* RO to indicate that the entity has been registered for VAT.
|
|
12
|
+
*
|
|
13
|
+
* Source:
|
|
14
|
+
* https://ro.wikipedia.org/wiki/Cod_de_identificare_fiscală
|
|
15
|
+
*
|
|
16
|
+
* ENTITY
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as exceptions from '../exceptions';
|
|
20
|
+
import { strings, weightedSum } from '../util';
|
|
21
|
+
import { Validator, ValidateReturn } from '../types';
|
|
22
|
+
|
|
23
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
24
|
+
return strings.cleanUnicode(input, ' -', 'RO');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const impl: Validator = {
|
|
28
|
+
name: 'Romanian Company Identifier',
|
|
29
|
+
localName: 'Codul Unic de Înregistrare',
|
|
30
|
+
abbreviation: 'CUI',
|
|
31
|
+
compact(input: string): string {
|
|
32
|
+
const [value, err] = clean(input);
|
|
33
|
+
|
|
34
|
+
if (err) {
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return value;
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
format(input: string): string {
|
|
42
|
+
const [value] = clean(input);
|
|
43
|
+
|
|
44
|
+
return strings.splitAt(value, 3, 6).join(' ');
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
validate(input: string): ValidateReturn {
|
|
48
|
+
const [value, error] = clean(input);
|
|
49
|
+
|
|
50
|
+
if (error) {
|
|
51
|
+
return { isValid: false, error };
|
|
52
|
+
}
|
|
53
|
+
if (value.length < 2 || value.length > 10) {
|
|
54
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
55
|
+
}
|
|
56
|
+
if (!strings.isdigits(value) || value[0] === '0') {
|
|
57
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const [front, check] = strings.splitAt(value.padStart(9, '0'), -1);
|
|
61
|
+
|
|
62
|
+
const sum =
|
|
63
|
+
10 *
|
|
64
|
+
weightedSum(front, {
|
|
65
|
+
weights: [7, 5, 3, 2, 1, 7, 5, 3, 2],
|
|
66
|
+
modulus: 11,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (String(sum % 10) !== check) {
|
|
70
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
isValid: true,
|
|
75
|
+
compact: value,
|
|
76
|
+
isIndividual: false,
|
|
77
|
+
isCompany: true,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
83
|
+
impl;
|
package/src/ro/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './onrc';
|
|
2
|
+
import { InvalidComponent } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ro/onrc', () => {
|
|
5
|
+
it('format:J52/750/2012', () => {
|
|
6
|
+
const result = format('J52/750/2012');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('J52/750/2012');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:J52/750/2012', () => {
|
|
12
|
+
const result = validate('J52/750/2012');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('J52/750/2012');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:J52/750/03.07.2012', () => {
|
|
18
|
+
const result = validate('J52/750/03.07.2012');
|
|
19
|
+
|
|
20
|
+
expect(result.isValid && result.compact).toEqual('J52/750/2012');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:X52/750/2012', () => {
|
|
24
|
+
const result = validate('X52/750/2012');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidComponent);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/ro/onrc.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NRC (Ordine din Registrul Comerţului, Romanian Trade Register identifier).
|
|
3
|
+
*
|
|
4
|
+
* All businesses in Romania have the to register with the National Trade
|
|
5
|
+
* Register Office to receive a registration number. The number contains
|
|
6
|
+
* information about the type of company, county, a sequence number and
|
|
7
|
+
* registration year. This number can change when registration information
|
|
8
|
+
* changes.
|
|
9
|
+
*
|
|
10
|
+
* Source
|
|
11
|
+
*
|
|
12
|
+
* ENTITY
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as exceptions from '../exceptions';
|
|
16
|
+
import { strings } from '../util';
|
|
17
|
+
import { Validator, ValidateReturn } from '../types';
|
|
18
|
+
|
|
19
|
+
const checkRe = /[A-Z]\d+\/\d{1,5}\/\d+/;
|
|
20
|
+
|
|
21
|
+
function* genit() {
|
|
22
|
+
for (let i = 0; i <= 41; i += 1) {
|
|
23
|
+
yield i;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
yield 51;
|
|
27
|
+
yield 52;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const counties = new Set(genit());
|
|
31
|
+
|
|
32
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
33
|
+
const [value, err] = strings.cleanUnicode(input, '');
|
|
34
|
+
|
|
35
|
+
if (err !== null) {
|
|
36
|
+
return [value, err];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const better = value
|
|
40
|
+
// Convert delimiters to '/'
|
|
41
|
+
.replace(/[ /\\-]+/g, '/')
|
|
42
|
+
// remove optional slash between first letter and county digits
|
|
43
|
+
.replace(/^([A-Z])\//, '$1')
|
|
44
|
+
// normalize country to 2 digits
|
|
45
|
+
.replace(/([A-Z])(\d)\//, '$10$2')
|
|
46
|
+
// clean full dates
|
|
47
|
+
.replace(/\/\d{2}[.]\d{2}[.](\d{4})$/, '/$1');
|
|
48
|
+
|
|
49
|
+
return [better, null];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const impl: Validator = {
|
|
53
|
+
name: 'Romanian Trade Register Identifier',
|
|
54
|
+
localName: 'Ordine din Registrul Comerţului',
|
|
55
|
+
abbreviation: 'NRC',
|
|
56
|
+
compact(input: string): string {
|
|
57
|
+
const [value, err] = clean(input);
|
|
58
|
+
|
|
59
|
+
if (err) {
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return value;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
format(input: string): string {
|
|
67
|
+
const [value] = clean(input);
|
|
68
|
+
|
|
69
|
+
return value;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
validate(input: string): ValidateReturn {
|
|
73
|
+
const [value, error] = clean(input);
|
|
74
|
+
|
|
75
|
+
if (error) {
|
|
76
|
+
return { isValid: false, error };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!checkRe.test(value)) {
|
|
80
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!'JFC'.includes(value[0])) {
|
|
84
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const [county, serial, year] = value.substr(1).split('/');
|
|
88
|
+
|
|
89
|
+
if (!counties.has(parseInt(county, 10))) {
|
|
90
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
91
|
+
}
|
|
92
|
+
if (serial.length > 5) {
|
|
93
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
94
|
+
}
|
|
95
|
+
if (year.length !== 4) {
|
|
96
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
isValid: true,
|
|
101
|
+
compact: value,
|
|
102
|
+
isIndividual: false,
|
|
103
|
+
isCompany: true,
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
109
|
+
impl;
|
package/src/rs/index.ts
ADDED
package/src/rs/jmbg.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serbian JMBG
|
|
3
|
+
* https://en.wikipedia.org/wiki/Unique_Master_Citizen_Number
|
|
4
|
+
*/
|
|
5
|
+
import { Validator } from '../types';
|
|
6
|
+
import * as jmbg from '../ba/jmbg';
|
|
7
|
+
|
|
8
|
+
const impl: Validator = {
|
|
9
|
+
...jmbg,
|
|
10
|
+
name: 'Serbian Unique Master Citizen Number',
|
|
11
|
+
localName: 'Јединствени матични број грађана',
|
|
12
|
+
abbreviation: 'ЈМБГ',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
16
|
+
impl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './pib';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('rs/pib', () => {
|
|
5
|
+
it('format:101134702', () => {
|
|
6
|
+
const result = format('101134702');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('101134702');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:101134702', () => {
|
|
12
|
+
const result = validate('101134702');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('101134702');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:1234567890', () => {
|
|
18
|
+
const result = validate('1234567890');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:101134701', () => {
|
|
24
|
+
const result = validate('101134701');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/rs/pib.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PIB (Poreski Identifikacioni Broj, Serbian tax identification number).
|
|
3
|
+
*
|
|
4
|
+
* The Serbian tax identification number consists of 9 digits where the last
|
|
5
|
+
* digit is a check digit.
|
|
6
|
+
*
|
|
7
|
+
* Source
|
|
8
|
+
* https://en.wikipedia.org/wiki/VAT_identification_number
|
|
9
|
+
*
|
|
10
|
+
* ENTITY
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as exceptions from '../exceptions';
|
|
14
|
+
import { strings } from '../util';
|
|
15
|
+
import { Validator, ValidateReturn } from '../types';
|
|
16
|
+
import { mod11mod10Validate } from '../util/checksum';
|
|
17
|
+
|
|
18
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
19
|
+
return strings.cleanUnicode(input, ' -.', 'RS');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const impl: Validator = {
|
|
23
|
+
name: 'Serbian Tax Identification Number',
|
|
24
|
+
localName: 'Poreski Identifikacioni Broj',
|
|
25
|
+
abbreviation: 'PIB',
|
|
26
|
+
compact(input: string): string {
|
|
27
|
+
const [value, err] = clean(input);
|
|
28
|
+
|
|
29
|
+
if (err) {
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return value;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
format(input: string): string {
|
|
37
|
+
const [value] = clean(input);
|
|
38
|
+
|
|
39
|
+
return value;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
validate(input: string): ValidateReturn {
|
|
43
|
+
const [value, error] = clean(input);
|
|
44
|
+
|
|
45
|
+
if (error) {
|
|
46
|
+
return { isValid: false, error };
|
|
47
|
+
}
|
|
48
|
+
if (value.length !== 9) {
|
|
49
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
50
|
+
}
|
|
51
|
+
if (!strings.isdigits(value)) {
|
|
52
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!mod11mod10Validate(value)) {
|
|
56
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
isValid: true,
|
|
61
|
+
compact: value,
|
|
62
|
+
isIndividual: false,
|
|
63
|
+
isCompany: true,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
69
|
+
impl;
|
package/src/ru/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as inn from './inn';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { validate } from './inn';
|
|
2
|
+
import { InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ru/inn', () => {
|
|
5
|
+
it('validate:123456789047', () => {
|
|
6
|
+
const result = validate('123456789047');
|
|
7
|
+
|
|
8
|
+
expect(result.isValid && result.compact).toEqual('123456789047');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:1234567894', () => {
|
|
12
|
+
const result = validate('1234567894');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('1234567894');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:366220664163', () => {
|
|
18
|
+
const result = validate('366220664163');
|
|
19
|
+
|
|
20
|
+
expect(result.isValid && result.compact).toEqual('366220664163');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:123456789037', () => {
|
|
24
|
+
const result = validate('123456789037');
|
|
25
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('format:1234567895', () => {
|
|
29
|
+
const result = validate('1234567895');
|
|
30
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
31
|
+
});
|
|
32
|
+
});
|
package/src/ru/inn.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ИНН (Идентификационный номер налогоплательщика, Russian tax identifier). (aka INN)
|
|
3
|
+
*
|
|
4
|
+
* The Indentifikatzionny nomer nalogoplatel'shchika is a Russian tax
|
|
5
|
+
* identification number that consists 10 digits for companies and 12 digits for
|
|
6
|
+
* persons.
|
|
7
|
+
*
|
|
8
|
+
* More information:
|
|
9
|
+
* https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/RussianFederation-TIN.pdf
|
|
10
|
+
*
|
|
11
|
+
* INN == VAT PERSON/ENTITY
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as exceptions from '../exceptions';
|
|
15
|
+
import { strings, weightedSum } from '../util';
|
|
16
|
+
import { Validator, ValidateReturn } from '../types';
|
|
17
|
+
|
|
18
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
19
|
+
return strings.cleanUnicode(input, ' ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const impl: Validator = {
|
|
23
|
+
name: 'Russian Tax Identifier',
|
|
24
|
+
localName: 'Идентификационный номер налогоплательщика',
|
|
25
|
+
abbreviation: 'ИНН',
|
|
26
|
+
|
|
27
|
+
compact(input: string): string {
|
|
28
|
+
const [value, err] = clean(input);
|
|
29
|
+
|
|
30
|
+
if (err) {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return value.toLocaleUpperCase();
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
format(input: string): string {
|
|
38
|
+
const [value] = clean(input);
|
|
39
|
+
|
|
40
|
+
return value;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if the number is a valid INN number.
|
|
45
|
+
* This checks the length, formatting and other contraints. It does not check
|
|
46
|
+
* for control letter.
|
|
47
|
+
*/
|
|
48
|
+
validate(input: string): ValidateReturn {
|
|
49
|
+
const [value, error] = clean(input);
|
|
50
|
+
|
|
51
|
+
if (error) {
|
|
52
|
+
return { isValid: false, error };
|
|
53
|
+
}
|
|
54
|
+
if (value.length !== 10 && value.length !== 12) {
|
|
55
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!strings.isdigits(value)) {
|
|
59
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let digit: string;
|
|
63
|
+
const [front, check] = strings.splitAt(
|
|
64
|
+
value,
|
|
65
|
+
value.length === 10 ? -1 : -2,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (value.length === 10) {
|
|
69
|
+
digit = String(
|
|
70
|
+
weightedSum(front, {
|
|
71
|
+
weights: [2, 4, 10, 3, 5, 9, 4, 6, 8],
|
|
72
|
+
modulus: 11,
|
|
73
|
+
}) % 10,
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
const d1 = String(
|
|
77
|
+
weightedSum(front, {
|
|
78
|
+
weights: [7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
|
|
79
|
+
modulus: 11,
|
|
80
|
+
}) % 10,
|
|
81
|
+
);
|
|
82
|
+
const d2 = String(
|
|
83
|
+
weightedSum(front + d1, {
|
|
84
|
+
weights: [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8],
|
|
85
|
+
modulus: 11,
|
|
86
|
+
}) % 10,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
digit = `${d1}${d2}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (digit !== check) {
|
|
93
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
isValid: true,
|
|
98
|
+
compact: value,
|
|
99
|
+
isIndividual: value.length === 12,
|
|
100
|
+
isCompany: value.length === 10,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
106
|
+
impl;
|
package/src/se/index.ts
ADDED