stdnum 1.9.16 → 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/at/vnr.js +2 -2
- package/lib/cjs/ba/jmbg.js +2 -2
- package/lib/cjs/cn/ric.js +2 -2
- package/lib/cjs/cu/ni.js +2 -2
- package/lib/cjs/cz/rc.js +2 -2
- package/lib/cjs/de/pwnr.js +2 -2
- package/lib/cjs/dk/cpr.js +7 -7
- package/lib/cjs/ee/ik.js +2 -2
- package/lib/cjs/fi/hetu.js +2 -3
- package/lib/cjs/gr/amka.js +2 -2
- package/lib/cjs/is/kennitala.js +2 -2
- package/lib/cjs/kr/rrn.js +2 -2
- package/lib/cjs/lv/pvn.js +2 -2
- package/lib/cjs/mx/curp.d.ts +1 -1
- package/lib/cjs/mx/curp.js +7 -11
- package/lib/cjs/mx/rfc.js +2 -2
- package/lib/cjs/my/nric.js +2 -2
- package/lib/cjs/no/fodselsnummer.js +3 -3
- package/lib/cjs/pl/pesel.js +2 -2
- package/lib/cjs/ro/cnp.js +2 -2
- package/lib/cjs/se/personnummer.js +34 -7
- package/lib/cjs/tw/tax_code.js +3 -3
- package/lib/cjs/util/index.d.ts +1 -1
- package/lib/cjs/util/index.js +4 -2
- package/lib/cjs/util/isValidDate.d.ts +6 -4
- package/lib/cjs/util/isValidDate.js +28 -12
- package/lib/cjs/za/idnr.js +2 -3
- package/lib/esm/at/vnr.js +2 -2
- package/lib/esm/ba/jmbg.js +3 -3
- package/lib/esm/cn/ric.js +2 -2
- package/lib/esm/cu/ni.js +3 -3
- package/lib/esm/cz/rc.js +3 -3
- package/lib/esm/de/pwnr.js +2 -2
- package/lib/esm/dk/cpr.js +8 -8
- package/lib/esm/ee/ik.js +2 -2
- package/lib/esm/fi/hetu.js +3 -4
- package/lib/esm/gr/amka.js +3 -3
- package/lib/esm/is/kennitala.js +3 -3
- package/lib/esm/kr/rrn.js +2 -2
- package/lib/esm/lv/pvn.js +3 -3
- package/lib/esm/mx/curp.d.ts +1 -1
- package/lib/esm/mx/curp.js +8 -12
- package/lib/esm/mx/rfc.js +2 -2
- package/lib/esm/my/nric.js +2 -2
- package/lib/esm/no/fodselsnummer.js +3 -3
- package/lib/esm/pl/pesel.js +2 -2
- package/lib/esm/ro/cnp.js +2 -2
- package/lib/esm/se/personnummer.js +35 -8
- package/lib/esm/tw/tax_code.js +3 -3
- package/lib/esm/util/index.d.ts +1 -1
- package/lib/esm/util/index.js +2 -2
- package/lib/esm/util/isValidDate.d.ts +6 -4
- package/lib/esm/util/isValidDate.js +25 -11
- package/lib/esm/za/idnr.js +3 -4
- 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/do/ncf.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NCF (Números de Comprobante Fiscal, Dominican Republic receipt number).
|
|
3
|
+
*
|
|
4
|
+
* The NCF is used to number invoices and other documents for the purpose of tax
|
|
5
|
+
* filing. The e-CF (Comprobante Fiscal Electrónico) is used together with a
|
|
6
|
+
* digital certificate for the same purpose. The number is either 19, 11 or 13
|
|
7
|
+
* (e-CF) digits long.
|
|
8
|
+
*
|
|
9
|
+
* The 19 digit number starts wit a letter (A or P) to indicate that the number
|
|
10
|
+
* was assigned by the taxpayer or the DGII, followed a 2-digit business unit
|
|
11
|
+
* number, a 3-digit location number, a 3-digit mechanism identifier, a 2-digit
|
|
12
|
+
* document type and a 8-digit serial number.
|
|
13
|
+
*
|
|
14
|
+
* The 11 digit number always starts with a B followed a 2-digit document type
|
|
15
|
+
* and a 7-digit serial number.
|
|
16
|
+
*
|
|
17
|
+
* The 13 digit e-CF starts with an E followed a 2-digit document type and an
|
|
18
|
+
* 8-digit serial number.
|
|
19
|
+
*
|
|
20
|
+
* Source
|
|
21
|
+
* https://www.dgii.gov.do/
|
|
22
|
+
* https://dgii.gov.do/workshopProveedoresTI-eCE/Documents/Norma05-19.pdf
|
|
23
|
+
* https://dgii.gov.do/cicloContribuyente/facturacion/comprobantesFiscales/Paginas/tiposComprobantes.aspx
|
|
24
|
+
*
|
|
25
|
+
* VAT ENTITY
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import * as exceptions from '../exceptions';
|
|
29
|
+
import { strings } from '../util';
|
|
30
|
+
import { Validator, ValidateReturn } from '../types';
|
|
31
|
+
|
|
32
|
+
const ncfTypes = [
|
|
33
|
+
'01', // invoices for fiscal declaration (or tax reporting)
|
|
34
|
+
'02', // invoices for final consumer
|
|
35
|
+
'03', // debit note
|
|
36
|
+
'04', // credit note (refunds)
|
|
37
|
+
'11', // informal supplier invoices (purchases)
|
|
38
|
+
'12', // single income invoices
|
|
39
|
+
'13', // minor expenses invoices (purchases)
|
|
40
|
+
'14', // invoices for special customers (tourists, free zones)
|
|
41
|
+
'15', // invoices for the government
|
|
42
|
+
'16', // invoices for export
|
|
43
|
+
'17', // invoices for payments abroad
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const ecfTypes = [
|
|
47
|
+
'31', // invoices for fiscal declaration (or tax reporting)
|
|
48
|
+
'32', // invoices for final consumer
|
|
49
|
+
'33', // debit note
|
|
50
|
+
'34', // credit note (refunds)
|
|
51
|
+
'41', // supplier invoices (purchases)
|
|
52
|
+
'43', // minor expenses invoices (purchases)
|
|
53
|
+
'44', // invoices for special customers (tourists, free zones)
|
|
54
|
+
'45', // invoices for the government
|
|
55
|
+
'46', // invoices for exports
|
|
56
|
+
'47', // invoices for foreign payments
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
60
|
+
return strings.cleanUnicode(input, ' ');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const impl: Validator = {
|
|
64
|
+
name: 'Dominican Republic Receipt Number',
|
|
65
|
+
localName: 'Números de Comprobante Fiscal',
|
|
66
|
+
abbreviation: 'NCF',
|
|
67
|
+
compact(input: string): string {
|
|
68
|
+
const [value, err] = clean(input);
|
|
69
|
+
|
|
70
|
+
if (err) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return value;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
format(input: string): string {
|
|
78
|
+
const [value] = clean(input);
|
|
79
|
+
|
|
80
|
+
return value;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
validate(input: string): ValidateReturn {
|
|
84
|
+
const [value, error] = clean(input);
|
|
85
|
+
|
|
86
|
+
if (error) {
|
|
87
|
+
return { isValid: false, error };
|
|
88
|
+
}
|
|
89
|
+
if (value.length === 13) {
|
|
90
|
+
if (!value.startsWith('E')) {
|
|
91
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
92
|
+
}
|
|
93
|
+
if (!strings.isdigits(value.substr(1))) {
|
|
94
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
95
|
+
}
|
|
96
|
+
if (!ecfTypes.includes(value.substr(1, 2))) {
|
|
97
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
98
|
+
}
|
|
99
|
+
} else if (value.length === 11) {
|
|
100
|
+
if (!value.startsWith('B')) {
|
|
101
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
102
|
+
}
|
|
103
|
+
if (!strings.isdigits(value.substr(1))) {
|
|
104
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
105
|
+
}
|
|
106
|
+
if (!ncfTypes.includes(value.substr(1, 2))) {
|
|
107
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
108
|
+
}
|
|
109
|
+
} else if (value.length === 19) {
|
|
110
|
+
if (!value.startsWith('AP')) {
|
|
111
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
112
|
+
}
|
|
113
|
+
if (!strings.isdigits(value.substr(2))) {
|
|
114
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
115
|
+
}
|
|
116
|
+
if (!ncfTypes.includes(value.substr(9, 2))) {
|
|
117
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
isValid: true,
|
|
125
|
+
compact: value,
|
|
126
|
+
isIndividual: false,
|
|
127
|
+
isCompany: true,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
133
|
+
impl;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { validate, format } from './rnc';
|
|
2
|
+
import { InvalidLength, InvalidChecksum, InvalidFormat } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('do/rnc', () => {
|
|
5
|
+
it('format:101850043', () => {
|
|
6
|
+
const result = format('101850043');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('1-01-85004-3');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:1-01-85004-3', () => {
|
|
12
|
+
const result = validate('1-01-85004-3');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('101850043');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:401505967', () => {
|
|
18
|
+
const result = validate('401505967');
|
|
19
|
+
|
|
20
|
+
expect(result.isValid && result.compact).toEqual('401505967');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:1018A0043', () => {
|
|
24
|
+
const result = validate('1018A0043');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidFormat);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('validate:10185004', () => {
|
|
30
|
+
const result = validate('10185004');
|
|
31
|
+
|
|
32
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('validate:101850042', () => {
|
|
36
|
+
const result = validate('101850042');
|
|
37
|
+
|
|
38
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/do/rnc.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RNC (Registro Nacional del Contribuyente, Dominican Republic tax number).
|
|
3
|
+
*
|
|
4
|
+
* The RNC is the Dominican Republic taxpayer registration number for
|
|
5
|
+
* institutions. The number consists of 9 digits.
|
|
6
|
+
*
|
|
7
|
+
* Source
|
|
8
|
+
*
|
|
9
|
+
* TAX ENTITY
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as exceptions from '../exceptions';
|
|
13
|
+
import { strings, weightedSum } from '../util';
|
|
14
|
+
import { Validator, ValidateReturn } from '../types';
|
|
15
|
+
|
|
16
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
17
|
+
return strings.cleanUnicode(input, ' -');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const impl: Validator = {
|
|
21
|
+
name: 'Dominican Republic Tax Number',
|
|
22
|
+
localName: 'Registro Nacional del Contribuyente',
|
|
23
|
+
abbreviation: 'RNC',
|
|
24
|
+
compact(input: string): string {
|
|
25
|
+
const [value, err] = clean(input);
|
|
26
|
+
|
|
27
|
+
if (err) {
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return value;
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
format(input: string): string {
|
|
35
|
+
const [value] = clean(input);
|
|
36
|
+
|
|
37
|
+
return strings.splitAt(value, 1, 3, -1).join('-');
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
validate(input: string): ValidateReturn {
|
|
41
|
+
const [value, error] = clean(input);
|
|
42
|
+
|
|
43
|
+
if (error) {
|
|
44
|
+
return { isValid: false, error };
|
|
45
|
+
}
|
|
46
|
+
if (value.length !== 9) {
|
|
47
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
48
|
+
}
|
|
49
|
+
if (!strings.isdigits(value)) {
|
|
50
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const [front, check] = strings.splitAt(value, 8);
|
|
54
|
+
|
|
55
|
+
const sum = weightedSum(front, {
|
|
56
|
+
weights: [7, 9, 8, 6, 5, 4, 3, 2],
|
|
57
|
+
modulus: 11,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (String(((10 - sum) % 9) + 1) !== check) {
|
|
61
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
isValid: true,
|
|
66
|
+
compact: value,
|
|
67
|
+
isIndividual: false,
|
|
68
|
+
isCompany: true,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
74
|
+
impl;
|
package/src/dz/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as nif from './nif';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { validate, format } from './nif';
|
|
2
|
+
import { InvalidLength, InvalidFormat } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('dz/nif', () => {
|
|
5
|
+
it('format:000 216 001 808 337 13010', () => {
|
|
6
|
+
const result = format('000 216 001 808 337 13010');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('00021600180833713010');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('fvalidate:000 216 001 808 337 13010', () => {
|
|
12
|
+
const result = validate('000 216 001 808 337 13010');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('00021600180833713010');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test.each([
|
|
18
|
+
'416001000000007',
|
|
19
|
+
'408 020 000 150 039',
|
|
20
|
+
'41201600000606600001',
|
|
21
|
+
'000 216 001 808 337 13010',
|
|
22
|
+
])('validate:%s', value => {
|
|
23
|
+
const result = validate(value);
|
|
24
|
+
|
|
25
|
+
expect(result.isValid).toEqual(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('validate:X1600100000000V', () => {
|
|
29
|
+
const result = validate('X1600100000000V');
|
|
30
|
+
|
|
31
|
+
expect(result.error).toBeInstanceOf(InvalidFormat);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('validate:41600100000000', () => {
|
|
35
|
+
const result = validate('41600100000000');
|
|
36
|
+
|
|
37
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
38
|
+
});
|
|
39
|
+
});
|
package/src/dz/nif.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NIF, sometimes N.I.F. (Numéro d'Identification Fiscale, Algeria tax number).
|
|
3
|
+
*
|
|
4
|
+
* The NIF was adopted by the Algerian tax authorities on 2006, replacing the NIS
|
|
5
|
+
* number.
|
|
6
|
+
*
|
|
7
|
+
* The NIF applies to physical persons, legal persons, legal entities,
|
|
8
|
+
* administrative entities, local branches for foreign companies, associations,
|
|
9
|
+
* professional organisations, etc.
|
|
10
|
+
*
|
|
11
|
+
* The NIF consists of 15 digits, but sometimes it can be 20 digits long in order
|
|
12
|
+
* to represent branches or secondary establishments.
|
|
13
|
+
*
|
|
14
|
+
* Source
|
|
15
|
+
* http://www.jecreemonentreprise.dz/index.php?option=com_content&view=article&id=612&Itemid=463&lang=fr
|
|
16
|
+
* https://www.mf.gov.dz/index.php/fr/fiscalite
|
|
17
|
+
* https://cnrcinfo.cnrc.dz/numero-didentification-fiscale-nif/
|
|
18
|
+
* https://nifenligne.mfdgi.gov.dz/
|
|
19
|
+
* http://nif.mfdgi.gov.dz/nif.asp
|
|
20
|
+
*
|
|
21
|
+
* ENTITY/PERSON
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import * as exceptions from '../exceptions';
|
|
25
|
+
import { strings } from '../util';
|
|
26
|
+
import { Validator, ValidateReturn } from '../types';
|
|
27
|
+
|
|
28
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
29
|
+
return strings.cleanUnicode(input, ' -');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// const validRe = /^[PCGQV]{1}00[A-Z0-9]{8}$/;
|
|
33
|
+
|
|
34
|
+
// const ALPHABET = '0123456789X';
|
|
35
|
+
|
|
36
|
+
const impl: Validator = {
|
|
37
|
+
name: 'Algeria tax number',
|
|
38
|
+
localName: "Numéro d'Identification Fiscale",
|
|
39
|
+
abbreviation: 'NIF',
|
|
40
|
+
|
|
41
|
+
compact(input: string): string {
|
|
42
|
+
const [value, err] = clean(input);
|
|
43
|
+
|
|
44
|
+
if (err) {
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return value;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
format(input: string): string {
|
|
52
|
+
const [value] = clean(input);
|
|
53
|
+
|
|
54
|
+
return value;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
validate(input: string): ValidateReturn {
|
|
58
|
+
const [value, error] = clean(input);
|
|
59
|
+
|
|
60
|
+
if (error) {
|
|
61
|
+
return { isValid: false, error };
|
|
62
|
+
}
|
|
63
|
+
if (value.length !== 15 && value.length !== 20) {
|
|
64
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
65
|
+
}
|
|
66
|
+
if (!strings.isdigits(value)) {
|
|
67
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
isValid: true,
|
|
72
|
+
compact: value,
|
|
73
|
+
isIndividual: false,
|
|
74
|
+
isCompany: false,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
80
|
+
impl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './ci';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ec/ci', () => {
|
|
5
|
+
it('format:1714307103', () => {
|
|
6
|
+
const result = format('1714307103');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('171430710-3');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:171430710-3', () => {
|
|
12
|
+
const result = validate('171430710-3');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('1714307103');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:171430710', () => {
|
|
18
|
+
const result = validate('171430710');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:1714307104', () => {
|
|
24
|
+
const result = validate('1714307104');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/ec/ci.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI (Cédula de identidad, Ecuadorian personal identity code).
|
|
3
|
+
*
|
|
4
|
+
* The CI is a 10 digit number used to identify Ecuadorian citizens.
|
|
5
|
+
*
|
|
6
|
+
* Source
|
|
7
|
+
*
|
|
8
|
+
* PERSON
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as exceptions from '../exceptions';
|
|
12
|
+
import { strings } from '../util';
|
|
13
|
+
import { Validator, ValidateReturn } from '../types';
|
|
14
|
+
|
|
15
|
+
function clean(input: string): ReturnType<typeof strings.cleanUnicode> {
|
|
16
|
+
return strings.cleanUnicode(input, ' -');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function validPrefix(value: string): boolean {
|
|
20
|
+
const prefix = parseInt(value.substr(0, 2), 10);
|
|
21
|
+
if (prefix === 0 || prefix > 24 || prefix === 30 || prefix === 50) {
|
|
22
|
+
// Invalid province
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const impl: Validator = {
|
|
30
|
+
name: 'Ecuadorian Personal Identity Code',
|
|
31
|
+
localName: 'Cédula de Identidad',
|
|
32
|
+
abbreviation: 'CI',
|
|
33
|
+
compact(input: string): string {
|
|
34
|
+
const [value, err] = clean(input);
|
|
35
|
+
|
|
36
|
+
if (err) {
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return value;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
format(input: string): string {
|
|
44
|
+
const [value] = clean(input);
|
|
45
|
+
|
|
46
|
+
return strings.splitAt(value, 9).join('-');
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
validate(input: string): ValidateReturn {
|
|
50
|
+
const [value, error] = clean(input);
|
|
51
|
+
|
|
52
|
+
if (error) {
|
|
53
|
+
return { isValid: false, error };
|
|
54
|
+
}
|
|
55
|
+
if (value.length !== 10) {
|
|
56
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
57
|
+
}
|
|
58
|
+
if (!strings.isdigits(value)) {
|
|
59
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!validPrefix(value)) {
|
|
63
|
+
// Invalid province
|
|
64
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
65
|
+
}
|
|
66
|
+
if (parseInt(value[2], 10) > 6) {
|
|
67
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const digit =
|
|
71
|
+
value
|
|
72
|
+
.split('')
|
|
73
|
+
.map(v => parseInt(v, 10))
|
|
74
|
+
.map((v, idx) => (idx % 2 === 0 ? v * 2 : v))
|
|
75
|
+
.map(v => (v > 9 ? v - 9 : v))
|
|
76
|
+
.reduce((acc, v) => acc + v) % 10;
|
|
77
|
+
|
|
78
|
+
if (digit !== 0) {
|
|
79
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
isValid: true,
|
|
84
|
+
compact: value,
|
|
85
|
+
isIndividual: true,
|
|
86
|
+
isCompany: false,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
92
|
+
impl;
|
package/src/ec/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { validate, format } from './ruc';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ec/ruc', () => {
|
|
5
|
+
it('format:1792060346001', () => {
|
|
6
|
+
const result = format('1792060346001');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('1792060346-001');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:1792060346-001', () => {
|
|
12
|
+
const result = validate('1792060346-001');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('1792060346001');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test.each(['0101016905001', '0962467429001', '1803557964001'])(
|
|
18
|
+
'validate:%s',
|
|
19
|
+
value => {
|
|
20
|
+
const result = validate(value);
|
|
21
|
+
|
|
22
|
+
expect(result.isValid).toEqual(true);
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
it('validate:1792060346-00', () => {
|
|
27
|
+
const result = validate('1792060346-00');
|
|
28
|
+
|
|
29
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('validate:1792060347-001', () => {
|
|
33
|
+
const result = validate('1792060347-001');
|
|
34
|
+
|
|
35
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
36
|
+
});
|
|
37
|
+
});
|
package/src/ec/ruc.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RUC (Registro Único de Contribuyentes, Ecuadorian company tax number).
|
|
3
|
+
*
|
|
4
|
+
* The RUC is a tax identification number for legal entities. It has 13 digits
|
|
5
|
+
* where the third digit is a number denoting the type of entity.
|
|
6
|
+
*
|
|
7
|
+
* Source
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* TAX/VAT
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as exceptions from '../exceptions';
|
|
14
|
+
import * as ci from './ci';
|
|
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: 'Ecuadorian Company Tax Number',
|
|
24
|
+
localName: 'Registro Único de Contribuyentes',
|
|
25
|
+
abbreviation: 'RUC',
|
|
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 strings.splitAt(value, 10).join('-');
|
|
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 !== 13) {
|
|
49
|
+
return { isValid: false, error: new exceptions.InvalidLength() };
|
|
50
|
+
}
|
|
51
|
+
if (!strings.isdigits(value)) {
|
|
52
|
+
return { isValid: false, error: new exceptions.InvalidFormat() };
|
|
53
|
+
}
|
|
54
|
+
if (!ci.validPrefix(value)) {
|
|
55
|
+
// Invalid province
|
|
56
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (parseInt(value[2], 10) < 6) {
|
|
60
|
+
// Natural RUC: CI plus establishment number
|
|
61
|
+
const [front, end] = strings.splitAt(value, 10);
|
|
62
|
+
if (end === '000') {
|
|
63
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return ci.validate(front);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (value[2] === '6') {
|
|
70
|
+
// Public RUC
|
|
71
|
+
const [front, end] = strings.splitAt(value, 9);
|
|
72
|
+
if (end === '0000') {
|
|
73
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
weightedSum(front, {
|
|
78
|
+
weights: [3, 2, 7, 6, 5, 4, 3, 2, 1],
|
|
79
|
+
modulus: 11,
|
|
80
|
+
}) !== 0
|
|
81
|
+
) {
|
|
82
|
+
// If it's not a public, try natural
|
|
83
|
+
if (end.endsWith('000')) {
|
|
84
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return ci.validate(value.substring(0, 10));
|
|
88
|
+
}
|
|
89
|
+
} else if (value[2] === '9') {
|
|
90
|
+
// Juridical RUC
|
|
91
|
+
const [front, end] = strings.splitAt(value, 10);
|
|
92
|
+
if (end === '000') {
|
|
93
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
94
|
+
}
|
|
95
|
+
if (
|
|
96
|
+
weightedSum(front, {
|
|
97
|
+
weights: [4, 3, 2, 7, 6, 5, 4, 3, 2, 1],
|
|
98
|
+
modulus: 11,
|
|
99
|
+
}) !== 0
|
|
100
|
+
) {
|
|
101
|
+
return { isValid: false, error: new exceptions.InvalidChecksum() };
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
return { isValid: false, error: new exceptions.InvalidComponent() };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
isValid: true,
|
|
109
|
+
compact: value,
|
|
110
|
+
isIndividual: false,
|
|
111
|
+
isCompany: true,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const { name, localName, abbreviation, validate, format, compact } =
|
|
117
|
+
impl;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { validate, format } from './ik';
|
|
2
|
+
import { InvalidLength, InvalidChecksum } from '../exceptions';
|
|
3
|
+
|
|
4
|
+
describe('ee/ik', () => {
|
|
5
|
+
it('format:36805280109', () => {
|
|
6
|
+
const result = format('36805280109');
|
|
7
|
+
|
|
8
|
+
expect(result).toEqual('36805280109');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('validate:36805280109', () => {
|
|
12
|
+
const result = validate('36805280109');
|
|
13
|
+
|
|
14
|
+
expect(result.isValid && result.compact).toEqual('36805280109');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('validate:12345678', () => {
|
|
18
|
+
const result = validate('12345678');
|
|
19
|
+
|
|
20
|
+
expect(result.error).toBeInstanceOf(InvalidLength);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('validate:36805280108', () => {
|
|
24
|
+
const result = validate('36805280108');
|
|
25
|
+
|
|
26
|
+
expect(result.error).toBeInstanceOf(InvalidChecksum);
|
|
27
|
+
});
|
|
28
|
+
});
|