stdnum 1.10.0 → 1.10.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/lib/cjs/no/fodselsnummer.js +2 -2
- package/lib/esm/no/fodselsnummer.js +2 -2
- 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 +28 -0
- package/src/tw/natid.ts +105 -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 +38 -0
- package/src/tw/ui.ts +107 -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/uy/rut.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RUT (Registro Único Tributario, Uruguay tax number).
|
|
3
|
+
*
|
|
4
|
+
* The Registro Único Tributario (RUT) is an identifier of legal entities for
|
|
5
|
+
* tax purposes.
|
|
6
|
+
*
|
|
7
|
+
* This number consists of 12 digits, the first two indicate the registration
|
|
8
|
+
* number, followed by a 6 digit sequence number, followed by 001 and a check
|
|
9
|
+
* digit.
|
|
10
|
+
*
|
|
11
|
+
* Source
|
|
12
|
+
* https://www.agesic.gub.uy/innovaportal/file/1634/1/modelo_de_datos.pdf (page 71)
|
|
13
|
+
* https://servicios.dgi.gub.uy/ServiciosEnLinea/dgi--servicios-en-linea--consulta-de-certifcado-unico
|
|
14
|
+
*
|
|
15
|
+
* ENTITY
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as exceptions from '../exceptions';
|
|
19
|
+
import { strings, weightedSum } from '../util';
|
|
20
|
+
import { Validator, ValidateReturn } from '../types';
|
|
21
|
+
import { pymod } from '../util/pymod';
|
|
22
|
+
|
|
23
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
24
|
+
const [value, err] = strings.cleanUnicode(input, ' -');
|
|
25
|
+
if (err) {
|
|
26
|
+
return [value, err];
|
|
27
|
+
}
|
|
28
|
+
if (value.startsWith('UY')) {
|
|
29
|
+
return [value.substr(2), null];
|
|
30
|
+
}
|
|
31
|
+
return [value, err];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const impl: Validator = {
|
|
35
|
+
name: 'Uruguayan Tax Number',
|
|
36
|
+
localName: 'Registro Único Tributario',
|
|
37
|
+
abbreviation: 'RUT',
|
|
38
|
+
compact(input: string): string {
|
|
39
|
+
const [value, err] = clean(input);
|
|
40
|
+
|
|
41
|
+
if (err) {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return value;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
format(input: string): string {
|
|
49
|
+
const [value] = clean(input);
|
|
50
|
+
|
|
51
|
+
return strings.splitAt(value, 2, -4, -1).join('-');
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
validate(input: string): ValidateReturn {
|
|
55
|
+
const [value, error] = clean(input);
|
|
56
|
+
|
|
57
|
+
if (error) {
|
|
58
|
+
return { isValid: false, error };
|
|
59
|
+
}
|
|
60
|
+
if (value.length !== 12) {
|
|
61
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
62
|
+
}
|
|
63
|
+
if (!strings.isdigits(value)) {
|
|
64
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
65
|
+
}
|
|
66
|
+
if (parseInt(value.substr(0, 2), 10) > 21 || value.substr(0, 2) === '00') {
|
|
67
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
68
|
+
}
|
|
69
|
+
if (value.substr(2, 6) === '000000') {
|
|
70
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
71
|
+
}
|
|
72
|
+
if (value.substr(8, 3) !== '001') {
|
|
73
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const [front, check] = strings.splitAt(value, 11);
|
|
77
|
+
|
|
78
|
+
const sum = weightedSum(front, {
|
|
79
|
+
weights: [4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2],
|
|
80
|
+
modulus: 11,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const digit = String(pymod(-sum, 11));
|
|
84
|
+
|
|
85
|
+
if (check !== digit) {
|
|
86
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
isValid: true,
|
|
91
|
+
compact: value,
|
|
92
|
+
isIndividual: false,
|
|
93
|
+
isCompany: true,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
99
|
+
impl;
|
package/src/ve/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as rif from './rif';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { validate, format } from './rif';
|
|
2
|
+
import {
|
|
3
|
+
InvalidLength,
|
|
4
|
+
InvalidComponent,
|
|
5
|
+
InvalidChecksum,
|
|
6
|
+
} from '../exceptions';
|
|
7
|
+
|
|
8
|
+
describe('ve/rif', () => {
|
|
9
|
+
it('format:V114702834', () => {
|
|
10
|
+
const result = format('V114702834');
|
|
11
|
+
|
|
12
|
+
expect(result).toEqual('V-11470283-4');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('validate:V-11470283-4', () => {
|
|
16
|
+
const result = validate('V-11470283-4');
|
|
17
|
+
|
|
18
|
+
expect(result.isValid && result.compact).toEqual('V114702834');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('validate:O-11470283-3', () => {
|
|
22
|
+
const result = validate('O-11470283-3');
|
|
23
|
+
|
|
24
|
+
expect(result.error).toBeInstanceOf(InvalidComponent);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('validate:12345678', () => {
|
|
28
|
+
const result = validate('12345678');
|
|
29
|
+
|
|
30
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('validate:V-11470283-3', () => {
|
|
34
|
+
const result = validate('V-11470283-3');
|
|
35
|
+
|
|
36
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
37
|
+
});
|
|
38
|
+
});
|
package/src/ve/rif.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RIF (Registro Único de Información Fiscal, Venezuelan VAT number).
|
|
3
|
+
*
|
|
4
|
+
* The Registro Único de Información Fiscal (RIF) is the Venezuelan fiscal
|
|
5
|
+
* registration number. The number consists of 10 digits where the first digit
|
|
6
|
+
* denotes the type of number (person, company or government) and the last digit
|
|
7
|
+
* is a check digit.
|
|
8
|
+
*
|
|
9
|
+
* Source
|
|
10
|
+
* https://wiki.scn.sap.com/wiki/display/CRM/Venezuela
|
|
11
|
+
* VAT
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as exceptions from '../exceptions';
|
|
15
|
+
import { strings, weightedSum } from '../util';
|
|
16
|
+
import { Validator, ValidateReturn } from '../types';
|
|
17
|
+
|
|
18
|
+
// Known number types and their corresponding value in the check
|
|
19
|
+
// digit calculation
|
|
20
|
+
const companyTypes: Record<string, number> = {
|
|
21
|
+
V: 4, // natural person born in Venezuela
|
|
22
|
+
E: 8, // foreign natural person
|
|
23
|
+
J: 12, // company
|
|
24
|
+
P: 16, // passport
|
|
25
|
+
G: 20, // government
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
29
|
+
return strings.cleanUnicode(input, ' -');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const impl: Validator = {
|
|
33
|
+
name: 'Venezuelan VAT Number',
|
|
34
|
+
localName: 'Registro Único de Información Fiscal',
|
|
35
|
+
abbreviation: 'RIF',
|
|
36
|
+
compact(input: string): string {
|
|
37
|
+
const [value, err] = clean(input);
|
|
38
|
+
|
|
39
|
+
if (err) {
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return value;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
format(input: string): string {
|
|
47
|
+
const [value] = clean(input);
|
|
48
|
+
|
|
49
|
+
return strings.splitAt(value, 1, 9).join('-');
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
validate(input: string): ValidateReturn {
|
|
53
|
+
const [value, error] = clean(input);
|
|
54
|
+
|
|
55
|
+
if (error) {
|
|
56
|
+
return { isValid: false, error };
|
|
57
|
+
}
|
|
58
|
+
if (value.length !== 10) {
|
|
59
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
60
|
+
}
|
|
61
|
+
if (!strings.isdigits(value.substr(1))) {
|
|
62
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
63
|
+
}
|
|
64
|
+
const [ctype, body, check] = strings.splitAt(value, 1, 9);
|
|
65
|
+
const first = companyTypes[ctype];
|
|
66
|
+
if (first === undefined) {
|
|
67
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const digit =
|
|
71
|
+
(first +
|
|
72
|
+
weightedSum(body, {
|
|
73
|
+
weights: [3, 2, 7, 6, 5, 4, 3, 2],
|
|
74
|
+
modulus: 11,
|
|
75
|
+
})) %
|
|
76
|
+
11;
|
|
77
|
+
|
|
78
|
+
if ('00987654321'[digit] !== check) {
|
|
79
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
isValid: true,
|
|
84
|
+
compact: value,
|
|
85
|
+
isIndividual: ['V', 'E'].includes(ctype),
|
|
86
|
+
isCompany: ['J', 'G', 'P'].includes(ctype),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
92
|
+
impl;
|
package/src/vn/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as mst from './mst';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { validate, format } from './mst';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('va/mst', () => {
|
|
5
|
+
it('format:01.00.112.437', () => {
|
|
6
|
+
const result = format('01.00.112.437');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('0100112437');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('format:0312 68 78 78 - 001', () => {
|
|
12
|
+
const result = format('0312 68 78 78 - 001');
|
|
13
|
+
|
|
14
|
+
expect(result).toEqual('0312687878-001');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:0100233488', () => {
|
|
18
|
+
const result = validate('0100233488');
|
|
19
|
+
|
|
20
|
+
expect(result.isValid && result.compact).toEqual('0100233488');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:0314409058-002', () => {
|
|
24
|
+
const result = validate('0314409058-002');
|
|
25
|
+
|
|
26
|
+
expect(result.isValid && result.compact).toEqual('0314409058002');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('validate:12345678', () => {
|
|
30
|
+
const result = validate('12345678');
|
|
31
|
+
|
|
32
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('validate:0100233480', () => {
|
|
36
|
+
const result = validate('0100233480');
|
|
37
|
+
|
|
38
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/vn/mst.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MST (Mã số thuế, Vietnam tax number).
|
|
3
|
+
*
|
|
4
|
+
* This number consists of 10 digits. Branches have a 13 digit number,
|
|
5
|
+
* where the first ten digits are the same as the parent company's.
|
|
6
|
+
*
|
|
7
|
+
* The first two digits is the province code where the business was
|
|
8
|
+
* established. If an enterprise relocates its head office from one
|
|
9
|
+
* province to another, ths MST will remain unchanged.
|
|
10
|
+
*
|
|
11
|
+
* The following seven digits are a sequential number from 0000001 to
|
|
12
|
+
* 9999999.
|
|
13
|
+
*
|
|
14
|
+
* The tenth digit is the check digit for the first nine digits, which is
|
|
15
|
+
* used to verify the number was correctly typed.
|
|
16
|
+
*
|
|
17
|
+
* The last optional three digits are a sequence from 001 to 999
|
|
18
|
+
* indicating branches of the enterprise. These digits are usually
|
|
19
|
+
* separated from the first ten digits using a dash (-)
|
|
20
|
+
*
|
|
21
|
+
* Source
|
|
22
|
+
* https://vi.wikipedia.org/wiki/Thuế_Việt_Nam#Mã_số_thuế_(MST)_của_doanh_nghiệp
|
|
23
|
+
* https://easyinvoice.vn/ma-so-thue/
|
|
24
|
+
* https://ub.com.vn/threads/huong-dan-tra-cuu-ma-so-thue-doanh-nghiep-moi-nhat.261393/
|
|
25
|
+
*
|
|
26
|
+
* /ENTITY
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import * as exceptions from '../exceptions';
|
|
30
|
+
import { strings } from '../util';
|
|
31
|
+
import { Validator, ValidateReturn } from '../types';
|
|
32
|
+
import { weightedSum } from '../util/checksum';
|
|
33
|
+
|
|
34
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
35
|
+
return strings.cleanUnicode(input, ' -.');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const impl: Validator = {
|
|
39
|
+
name: 'Vietnamese Tax Number',
|
|
40
|
+
localName: 'Mã số thuế',
|
|
41
|
+
abbreviation: 'MST',
|
|
42
|
+
compact(input: string): string {
|
|
43
|
+
const [value, err] = clean(input);
|
|
44
|
+
|
|
45
|
+
if (err) {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
format(input: string): string {
|
|
53
|
+
const [value] = clean(input);
|
|
54
|
+
|
|
55
|
+
return strings.splitAt(value, 10).join('-');
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
validate(input: string): ValidateReturn {
|
|
59
|
+
const [value, error] = clean(input);
|
|
60
|
+
|
|
61
|
+
if (error) {
|
|
62
|
+
return { isValid: false, error };
|
|
63
|
+
}
|
|
64
|
+
if (value.length !== 10 && value.length !== 13) {
|
|
65
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
66
|
+
}
|
|
67
|
+
if (!strings.isdigits(value)) {
|
|
68
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
69
|
+
}
|
|
70
|
+
const [province, sequence, check, suffix] = strings.splitAt(
|
|
71
|
+
value,
|
|
72
|
+
2,
|
|
73
|
+
9,
|
|
74
|
+
10,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (sequence === '0000000' || suffix === '000' || province === '00') {
|
|
78
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const sum = weightedSum(value.substr(0, 9), {
|
|
82
|
+
modulus: 11,
|
|
83
|
+
weights: [31, 29, 23, 19, 17, 13, 7, 5, 3],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (check !== String(10 - sum)) {
|
|
87
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
isValid: true,
|
|
92
|
+
compact: value,
|
|
93
|
+
isIndividual: false,
|
|
94
|
+
isCompany: true,
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
100
|
+
impl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './idnr';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('za/idnr', () => {
|
|
5
|
+
it('format:7503305044089', () => {
|
|
6
|
+
const result = format('7503305044089');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('7503305044089');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:7503305044089', () => {
|
|
12
|
+
const result = validate('7503305044089');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('7503305044089');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:12345678', () => {
|
|
18
|
+
const result = validate('12345678');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:8503305044089', () => {
|
|
24
|
+
const result = validate('8503305044089');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/za/idnr.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ID number (South African Identity Document number).
|
|
3
|
+
*
|
|
4
|
+
* The South African ID number is issued to individuals within South Africa. The
|
|
5
|
+
* number consists of 13 digits and contains information about a person's date
|
|
6
|
+
* of birth, gender and whether the person is a citizen or permanent resident.
|
|
7
|
+
*
|
|
8
|
+
* Source
|
|
9
|
+
* https://en.wikipedia.org/wiki/South_African_identity_card
|
|
10
|
+
* http://www.dha.gov.za/index.php/identity-documents2
|
|
11
|
+
*
|
|
12
|
+
* PERSON
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as exceptions from '../exceptions';
|
|
16
|
+
import { strings, isValidDateCompactYYMMDD } from '../util';
|
|
17
|
+
import { Validator, ValidateReturn } from '../types';
|
|
18
|
+
import { luhnChecksumValidate } from '../util/checksum';
|
|
19
|
+
|
|
20
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
21
|
+
return strings.cleanUnicode(input, ' ');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const impl: Validator = {
|
|
25
|
+
name: 'South African Identity Document Number',
|
|
26
|
+
localName: 'Identity Document Number',
|
|
27
|
+
abbreviation: 'IDNR',
|
|
28
|
+
compact(input: string): string {
|
|
29
|
+
const [value, err] = clean(input);
|
|
30
|
+
|
|
31
|
+
if (err) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
format(input: string): string {
|
|
39
|
+
const [value] = clean(input);
|
|
40
|
+
|
|
41
|
+
return value;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
validate(input: string): ValidateReturn {
|
|
45
|
+
const [value, error] = clean(input);
|
|
46
|
+
|
|
47
|
+
if (error) {
|
|
48
|
+
return { isValid: false, error };
|
|
49
|
+
}
|
|
50
|
+
if (value.length !== 13) {
|
|
51
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
52
|
+
}
|
|
53
|
+
if (!strings.isdigits(value)) {
|
|
54
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const [bdate, gender, , citizen] = strings.splitAt(value, 6, 7, 10, 11);
|
|
58
|
+
|
|
59
|
+
if (!'01'.includes(citizen)) {
|
|
60
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
61
|
+
}
|
|
62
|
+
if (!strings.isdigits(gender)) {
|
|
63
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!isValidDateCompactYYMMDD(bdate, true)) {
|
|
67
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!luhnChecksumValidate(value)) {
|
|
71
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
isValid: true,
|
|
76
|
+
compact: value,
|
|
77
|
+
isIndividual: true,
|
|
78
|
+
isCompany: false,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
84
|
+
impl;
|
package/src/za/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './tin';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('za/tin', () => {
|
|
5
|
+
it('format:2449/494-16-0', () => {
|
|
6
|
+
const result = format('2449/494-16-0');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('2449494160');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:0001339050', () => {
|
|
12
|
+
const result = validate('0001339050');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('0001339050');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:12345678', () => {
|
|
18
|
+
const result = validate('12345678');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:2449/494/16/0', () => {
|
|
24
|
+
const result = validate('2449/494/16/0');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/za/tin.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TIN (South African Tax Identification Number).
|
|
3
|
+
*
|
|
4
|
+
* The South African Tax Identification Number (TIN or Tax Reference Number) is
|
|
5
|
+
* issued to individuals and legal entities for tax purposes. The number
|
|
6
|
+
* consists of 10 digits.
|
|
7
|
+
*
|
|
8
|
+
* Source
|
|
9
|
+
* https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/South-Africa-TIN.pdf
|
|
10
|
+
* https://www.sars.gov.za/
|
|
11
|
+
*
|
|
12
|
+
* PERSON/ENTITY
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as exceptions from '../exceptions';
|
|
16
|
+
import { strings } from '../util';
|
|
17
|
+
import { Validator, ValidateReturn } from '../types';
|
|
18
|
+
import { luhnChecksumValidate } from '../util/checksum';
|
|
19
|
+
|
|
20
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
21
|
+
return strings.cleanUnicode(input, ' -/');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const impl: Validator = {
|
|
25
|
+
name: 'South African Tax Identification Number',
|
|
26
|
+
localName: 'Tax Identification Number',
|
|
27
|
+
abbreviation: 'TIN',
|
|
28
|
+
compact(input: string): string {
|
|
29
|
+
const [value, err] = clean(input);
|
|
30
|
+
|
|
31
|
+
if (err) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
format(input: string): string {
|
|
39
|
+
const [value] = clean(input);
|
|
40
|
+
|
|
41
|
+
return value;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
validate(input: string): ValidateReturn {
|
|
45
|
+
const [value, error] = clean(input);
|
|
46
|
+
|
|
47
|
+
if (error) {
|
|
48
|
+
return { isValid: false, error };
|
|
49
|
+
}
|
|
50
|
+
if (value.length !== 10) {
|
|
51
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
52
|
+
}
|
|
53
|
+
if (!strings.isdigits(value)) {
|
|
54
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!'01239'.includes(value[0])) {
|
|
58
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!luhnChecksumValidate(value)) {
|
|
62
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
isValid: true,
|
|
67
|
+
compact: value,
|
|
68
|
+
isIndividual: true, // TIN can be either. cannot determine
|
|
69
|
+
isCompany: true, // TIN can be either. cannot determine
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
75
|
+
impl;
|