@stll/stdnum 2.1.1 → 2.1.3
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/dist/_virtual/_rolldown/runtime.js +1 -0
- package/dist/ad/mod.d.ts +0 -2
- package/dist/ad/mod.js +1 -1
- package/dist/ad/mod.js.map +1 -1
- package/dist/ad/nrt.d.ts +4 -21
- package/dist/ad/nrt.js +9 -53
- package/dist/ad/nrt.js.map +1 -1
- package/dist/ae/eid.d.ts +3 -9
- package/dist/ae/eid.js +9 -65
- package/dist/ae/eid.js.map +1 -1
- package/dist/ae/mod.d.ts +0 -2
- package/dist/ae/mod.js +1 -1
- package/dist/ae/mod.js.map +1 -1
- package/dist/ai/mod.d.ts +0 -2
- package/dist/ai/mod.js +1 -1
- package/dist/ai/mod.js.map +1 -1
- package/dist/ai/tin.d.ts +4 -31
- package/dist/ai/tin.js +9 -51
- package/dist/ai/tin.js.map +1 -1
- package/dist/al/mod.d.ts +0 -2
- package/dist/al/mod.js +1 -1
- package/dist/al/mod.js.map +1 -1
- package/dist/al/nipt.d.ts +4 -18
- package/dist/al/nipt.js +9 -42
- package/dist/al/nipt.js.map +1 -1
- package/dist/am/mod.d.ts +0 -2
- package/dist/am/mod.js +1 -1
- package/dist/am/mod.js.map +1 -1
- package/dist/am/tin.d.ts +4 -21
- package/dist/am/tin.js +9 -36
- package/dist/am/tin.js.map +1 -1
- package/dist/ar/cbu.d.ts +3 -6
- package/dist/ar/cbu.js +9 -76
- package/dist/ar/cbu.js.map +1 -1
- package/dist/ar/cuit.d.ts +3 -11
- package/dist/ar/cuit.js +9 -103
- package/dist/ar/cuit.js.map +1 -1
- package/dist/ar/dni.d.ts +4 -16
- package/dist/ar/dni.js +9 -45
- package/dist/ar/dni.js.map +1 -1
- package/dist/ar/mod.d.ts +0 -2
- package/dist/ar/mod.js +1 -1
- package/dist/ar/mod.js.map +1 -1
- package/dist/at/businessid.d.ts +4 -15
- package/dist/at/businessid.js +9 -45
- package/dist/at/businessid.js.map +1 -1
- package/dist/at/mod.d.ts +0 -2
- package/dist/at/mod.js +1 -1
- package/dist/at/mod.js.map +1 -1
- package/dist/at/tin.d.ts +3 -6
- package/dist/at/tin.js +9 -56
- package/dist/at/tin.js.map +1 -1
- package/dist/at/uid.d.ts +3 -6
- package/dist/at/uid.js +9 -52
- package/dist/at/uid.js.map +1 -1
- package/dist/at/vnr.d.ts +3 -6
- package/dist/at/vnr.js +9 -82
- package/dist/at/vnr.js.map +1 -1
- package/dist/au/abn.d.ts +3 -6
- package/dist/au/abn.js +9 -64
- package/dist/au/abn.js.map +1 -1
- package/dist/au/acn.d.ts +3 -6
- package/dist/au/acn.js +9 -57
- package/dist/au/acn.js.map +1 -1
- package/dist/au/mod.d.ts +0 -2
- package/dist/au/mod.js +1 -1
- package/dist/au/mod.js.map +1 -1
- package/dist/au/tfn.d.ts +3 -6
- package/dist/au/tfn.js +9 -58
- package/dist/au/tfn.js.map +1 -1
- package/dist/az/mod.d.ts +0 -2
- package/dist/az/mod.js +1 -1
- package/dist/az/mod.js.map +1 -1
- package/dist/az/voen.d.ts +3 -13
- package/dist/az/voen.js +9 -83
- package/dist/az/voen.js.map +1 -1
- package/dist/ba/jmbg.d.ts +5 -8
- package/dist/ba/jmbg.js +10 -86
- package/dist/ba/jmbg.js.map +1 -1
- package/dist/ba/mod.d.ts +0 -2
- package/dist/ba/mod.js +1 -1
- package/dist/ba/mod.js.map +1 -1
- package/dist/bd/mod.d.ts +0 -2
- package/dist/bd/mod.js +1 -1
- package/dist/bd/mod.js.map +1 -1
- package/dist/bd/nid.d.ts +4 -28
- package/dist/bd/nid.js +9 -91
- package/dist/bd/nid.js.map +1 -1
- package/dist/be/bis.d.ts +3 -6
- package/dist/be/bis.js +9 -51
- package/dist/be/bis.js.map +1 -1
- package/dist/be/mod.d.ts +0 -2
- package/dist/be/mod.js +2 -2
- package/dist/be/mod.js.map +1 -1
- package/dist/be/nn.d.ts +4 -13
- package/dist/be/nn.js +10 -70
- package/dist/be/nn.js.map +1 -1
- package/dist/be/vat.d.ts +3 -6
- package/dist/be/vat.js +9 -58
- package/dist/be/vat.js.map +1 -1
- package/dist/bg/egn.d.ts +5 -12
- package/dist/bg/egn.js +10 -110
- package/dist/bg/egn.js.map +1 -1
- package/dist/bg/mod.d.ts +0 -2
- package/dist/bg/mod.js +1 -1
- package/dist/bg/mod.js.map +1 -1
- package/dist/bg/pnf.d.ts +3 -6
- package/dist/bg/pnf.js +9 -59
- package/dist/bg/pnf.js.map +1 -1
- package/dist/bg/vat.d.ts +3 -6
- package/dist/bg/vat.js +9 -143
- package/dist/bg/vat.js.map +1 -1
- package/dist/bh/cpr.d.ts +3 -6
- package/dist/bh/cpr.js +9 -44
- package/dist/bh/cpr.js.map +1 -1
- package/dist/bh/mod.d.ts +0 -2
- package/dist/bh/mod.js +1 -1
- package/dist/bh/mod.js.map +1 -1
- package/dist/bic.d.ts +4 -18
- package/dist/bic.js +9 -56
- package/dist/bic.js.map +1 -1
- package/dist/br/cnpj.d.ts +3 -13
- package/dist/br/cnpj.js +9 -109
- package/dist/br/cnpj.js.map +1 -1
- package/dist/br/cpf.d.ts +3 -6
- package/dist/br/cpf.js +9 -66
- package/dist/br/cpf.js.map +1 -1
- package/dist/br/mod.d.ts +0 -2
- package/dist/br/mod.js +1 -1
- package/dist/br/mod.js.map +1 -1
- package/dist/by/mod.d.ts +0 -2
- package/dist/by/mod.js +1 -1
- package/dist/by/mod.js.map +1 -1
- package/dist/by/unp.d.ts +3 -6
- package/dist/by/unp.js +9 -102
- package/dist/by/unp.js.map +1 -1
- package/dist/bz/mod.d.ts +0 -2
- package/dist/bz/mod.js +1 -1
- package/dist/bz/mod.js.map +1 -1
- package/dist/bz/tin.d.ts +3 -10
- package/dist/bz/tin.js +9 -64
- package/dist/bz/tin.js.map +1 -1
- package/dist/ca/bn.d.ts +3 -6
- package/dist/ca/bn.js +9 -61
- package/dist/ca/bn.js.map +1 -1
- package/dist/ca/mod.d.ts +0 -2
- package/dist/ca/mod.js +1 -1
- package/dist/ca/mod.js.map +1 -1
- package/dist/ca/sin.d.ts +3 -6
- package/dist/ca/sin.js +9 -50
- package/dist/ca/sin.js.map +1 -1
- package/dist/catalog.d.ts +9 -0
- package/dist/catalog.js +9 -0
- package/dist/catalog.js.map +1 -0
- package/dist/ch/mod.d.ts +1 -3
- package/dist/ch/mod.js +2 -2
- package/dist/ch/mod.js.map +1 -1
- package/dist/ch/ssn.d.ts +3 -6
- package/dist/ch/ssn.js +9 -55
- package/dist/ch/ssn.js.map +1 -1
- package/dist/ch/uid.d.ts +3 -6
- package/dist/ch/uid.js +9 -69
- package/dist/ch/uid.js.map +1 -1
- package/dist/ch/vat.d.ts +3 -6
- package/dist/ch/vat.js +9 -58
- package/dist/ch/vat.js.map +1 -1
- package/dist/cl/mod.d.ts +0 -2
- package/dist/cl/mod.js +1 -1
- package/dist/cl/mod.js.map +1 -1
- package/dist/cl/rut.d.ts +3 -11
- package/dist/cl/rut.js +9 -78
- package/dist/cl/rut.js.map +1 -1
- package/dist/cn/mod.d.ts +0 -2
- package/dist/cn/mod.js +1 -1
- package/dist/cn/mod.js.map +1 -1
- package/dist/cn/ric.d.ts +5 -12
- package/dist/cn/ric.js +10 -94
- package/dist/cn/ric.js.map +1 -1
- package/dist/cn/uscc.d.ts +3 -6
- package/dist/cn/uscc.js +9 -76
- package/dist/cn/uscc.js.map +1 -1
- package/dist/co/mod.d.ts +0 -2
- package/dist/co/mod.js +1 -1
- package/dist/co/mod.js.map +1 -1
- package/dist/co/nit.d.ts +3 -6
- package/dist/co/nit.js +9 -98
- package/dist/co/nit.js.map +1 -1
- package/dist/cr/cpf.d.ts +4 -31
- package/dist/cr/cpf.js +9 -61
- package/dist/cr/cpf.js.map +1 -1
- package/dist/cr/mod.d.ts +0 -2
- package/dist/cr/mod.js +1 -1
- package/dist/cr/mod.js.map +1 -1
- package/dist/creditcard.d.ts +5 -18
- package/dist/creditcard.js +8 -109
- package/dist/creditcard.js.map +1 -1
- package/dist/crypto/btcbase58.d.ts +5 -6
- package/dist/crypto/btcbase58.js +8 -73
- package/dist/crypto/btcbase58.js.map +1 -1
- package/dist/crypto/btcbech32.d.ts +7 -9
- package/dist/crypto/btcbech32.js +10 -142
- package/dist/crypto/btcbech32.js.map +1 -1
- package/dist/crypto/eth.d.ts +4 -5
- package/dist/crypto/eth.js +7 -59
- package/dist/crypto/eth.js.map +1 -1
- package/dist/crypto/mod.d.ts +4 -6
- package/dist/crypto/mod.js +6 -6
- package/dist/crypto/mod.js.map +1 -1
- package/dist/crypto/wallet.d.ts +3 -4
- package/dist/crypto/wallet.js +6 -51
- package/dist/crypto/wallet.js.map +1 -1
- package/dist/cu/mod.d.ts +0 -2
- package/dist/cu/mod.js +1 -1
- package/dist/cu/mod.js.map +1 -1
- package/dist/cu/ni.d.ts +5 -16
- package/dist/cu/ni.js +10 -81
- package/dist/cu/ni.js.map +1 -1
- package/dist/cy/mod.d.ts +0 -2
- package/dist/cy/mod.js +1 -1
- package/dist/cy/mod.js.map +1 -1
- package/dist/cy/vat.d.ts +3 -6
- package/dist/cy/vat.js +9 -77
- package/dist/cy/vat.js.map +1 -1
- package/dist/cz/dic.d.ts +3 -6
- package/dist/cz/dic.js +9 -87
- package/dist/cz/dic.js.map +1 -1
- package/dist/cz/ico.d.ts +3 -6
- package/dist/cz/ico.js +9 -58
- package/dist/cz/ico.js.map +1 -1
- package/dist/cz/mod.d.ts +0 -2
- package/dist/cz/mod.js +2 -2
- package/dist/cz/mod.js.map +1 -1
- package/dist/cz/rc.d.ts +5 -15
- package/dist/cz/rc.js +10 -113
- package/dist/cz/rc.js.map +1 -1
- package/dist/de/handelsreg.d.ts +4 -28
- package/dist/de/handelsreg.js +9 -66
- package/dist/de/handelsreg.js.map +1 -1
- package/dist/de/idnr.d.ts +3 -6
- package/dist/de/idnr.js +9 -88
- package/dist/de/idnr.js.map +1 -1
- package/dist/de/mod.d.ts +0 -2
- package/dist/de/mod.js +1 -1
- package/dist/de/mod.js.map +1 -1
- package/dist/de/stnr.d.ts +4 -30
- package/dist/de/stnr.js +9 -126
- package/dist/de/stnr.js.map +1 -1
- package/dist/de/svnr.d.ts +3 -6
- package/dist/de/svnr.js +9 -95
- package/dist/de/svnr.js.map +1 -1
- package/dist/de/vat.d.ts +3 -6
- package/dist/de/vat.js +9 -52
- package/dist/de/vat.js.map +1 -1
- package/dist/dk/cpr.d.ts +5 -12
- package/dist/dk/cpr.js +10 -79
- package/dist/dk/cpr.js.map +1 -1
- package/dist/dk/cvr.d.ts +3 -6
- package/dist/dk/cvr.js +9 -53
- package/dist/dk/cvr.js.map +1 -1
- package/dist/dk/mod.d.ts +0 -2
- package/dist/dk/mod.js +1 -1
- package/dist/dk/mod.js.map +1 -1
- package/dist/dk/vat.d.ts +3 -6
- package/dist/dk/vat.js +9 -58
- package/dist/dk/vat.js.map +1 -1
- package/dist/do/mod.d.ts +0 -2
- package/dist/do/mod.js +1 -1
- package/dist/do/mod.js.map +1 -1
- package/dist/do/rnc.d.ts +3 -10
- package/dist/do/rnc.js +9 -77
- package/dist/do/rnc.js.map +1 -1
- package/dist/ec/mod.d.ts +0 -2
- package/dist/ec/mod.js +1 -1
- package/dist/ec/mod.js.map +1 -1
- package/dist/ec/ruc.d.ts +3 -6
- package/dist/ec/ruc.js +9 -129
- package/dist/ec/ruc.js.map +1 -1
- package/dist/ee/ik.d.ts +6 -17
- package/dist/ee/ik.js +11 -118
- package/dist/ee/ik.js.map +1 -1
- package/dist/ee/mod.d.ts +0 -2
- package/dist/ee/mod.js +1 -1
- package/dist/ee/mod.js.map +1 -1
- package/dist/ee/registrikood.d.ts +3 -6
- package/dist/ee/registrikood.js +9 -53
- package/dist/ee/registrikood.js.map +1 -1
- package/dist/ee/vat.d.ts +3 -6
- package/dist/ee/vat.js +9 -57
- package/dist/ee/vat.js.map +1 -1
- package/dist/eg/mod.d.ts +0 -2
- package/dist/eg/mod.js +1 -1
- package/dist/eg/mod.js.map +1 -1
- package/dist/eg/tn.d.ts +4 -16
- package/dist/eg/tn.js +9 -69
- package/dist/eg/tn.js.map +1 -1
- package/dist/es/cif.d.ts +3 -6
- package/dist/es/cif.js +9 -53
- package/dist/es/cif.js.map +1 -1
- package/dist/es/dni.d.ts +4 -7
- package/dist/es/dni.js +9 -45
- package/dist/es/dni.js.map +1 -1
- package/dist/es/mod.d.ts +0 -2
- package/dist/es/mod.js +2 -2
- package/dist/es/mod.js.map +1 -1
- package/dist/es/nie.d.ts +3 -6
- package/dist/es/nie.js +9 -66
- package/dist/es/nie.js.map +1 -1
- package/dist/es/nss.d.ts +3 -6
- package/dist/es/nss.js +9 -53
- package/dist/es/nss.js.map +1 -1
- package/dist/es/vat.d.ts +4 -7
- package/dist/es/vat.js +10 -95
- package/dist/es/vat.js.map +1 -1
- package/dist/eu/mod.d.ts +3 -5
- package/dist/eu/mod.js +4 -4
- package/dist/eu/mod.js.map +1 -1
- package/dist/eu/vat.d.ts +4 -15
- package/dist/eu/vat.js +10 -184
- package/dist/eu/vat.js.map +1 -1
- package/dist/fi/hetu.d.ts +5 -12
- package/dist/fi/hetu.js +10 -110
- package/dist/fi/hetu.js.map +1 -1
- package/dist/fi/mod.d.ts +0 -2
- package/dist/fi/mod.js +2 -2
- package/dist/fi/mod.js.map +1 -1
- package/dist/fi/vat.d.ts +3 -6
- package/dist/fi/vat.js +9 -57
- package/dist/fi/vat.js.map +1 -1
- package/dist/fi/ytunnus.d.ts +3 -6
- package/dist/fi/ytunnus.js +9 -59
- package/dist/fi/ytunnus.js.map +1 -1
- package/dist/fr/mod.d.ts +0 -2
- package/dist/fr/mod.js +2 -2
- package/dist/fr/mod.js.map +1 -1
- package/dist/fr/nif.d.ts +3 -6
- package/dist/fr/nif.js +9 -52
- package/dist/fr/nif.js.map +1 -1
- package/dist/fr/nir.d.ts +5 -8
- package/dist/fr/nir.js +10 -91
- package/dist/fr/nir.js.map +1 -1
- package/dist/fr/siren.d.ts +3 -6
- package/dist/fr/siren.js +9 -44
- package/dist/fr/siren.js.map +1 -1
- package/dist/fr/siret.d.ts +3 -6
- package/dist/fr/siret.js +9 -60
- package/dist/fr/siret.js.map +1 -1
- package/dist/fr/tva.d.ts +3 -6
- package/dist/fr/tva.js +9 -66
- package/dist/fr/tva.js.map +1 -1
- package/dist/gb/mod.d.ts +0 -2
- package/dist/gb/mod.js +2 -2
- package/dist/gb/mod.js.map +1 -1
- package/dist/gb/nhs.d.ts +4 -5
- package/dist/gb/nhs.js +7 -47
- package/dist/gb/nhs.js.map +1 -1
- package/dist/gb/nino.d.ts +4 -17
- package/dist/gb/nino.js +9 -90
- package/dist/gb/nino.js.map +1 -1
- package/dist/gb/sedol.d.ts +4 -7
- package/dist/gb/sedol.js +10 -72
- package/dist/gb/sedol.js.map +1 -1
- package/dist/gb/utr.d.ts +3 -6
- package/dist/gb/utr.js +9 -57
- package/dist/gb/utr.js.map +1 -1
- package/dist/gb/vat.d.ts +3 -6
- package/dist/gb/vat.js +9 -89
- package/dist/gb/vat.js.map +1 -1
- package/dist/ge/mod.d.ts +0 -2
- package/dist/ge/mod.js +1 -1
- package/dist/ge/mod.js.map +1 -1
- package/dist/ge/pin.d.ts +4 -19
- package/dist/ge/pin.js +9 -36
- package/dist/ge/pin.js.map +1 -1
- package/dist/gh/mod.d.ts +0 -2
- package/dist/gh/mod.js +1 -1
- package/dist/gh/mod.js.map +1 -1
- package/dist/gh/tin.d.ts +3 -6
- package/dist/gh/tin.js +9 -62
- package/dist/gh/tin.js.map +1 -1
- package/dist/gr/amka.d.ts +3 -6
- package/dist/gr/amka.js +9 -59
- package/dist/gr/amka.js.map +1 -1
- package/dist/gr/mod.d.ts +0 -2
- package/dist/gr/mod.js +2 -2
- package/dist/gr/mod.js.map +1 -1
- package/dist/gr/vat.d.ts +3 -6
- package/dist/gr/vat.js +9 -53
- package/dist/gr/vat.js.map +1 -1
- package/dist/gt/mod.d.ts +0 -2
- package/dist/gt/mod.js +1 -1
- package/dist/gt/mod.js.map +1 -1
- package/dist/gt/nit.d.ts +3 -13
- package/dist/gt/nit.js +9 -86
- package/dist/gt/nit.js.map +1 -1
- package/dist/hk/hkid.d.ts +3 -7
- package/dist/hk/hkid.js +9 -80
- package/dist/hk/hkid.js.map +1 -1
- package/dist/hk/mod.d.ts +0 -2
- package/dist/hk/mod.js +1 -1
- package/dist/hk/mod.js.map +1 -1
- package/dist/hr/mod.d.ts +0 -2
- package/dist/hr/mod.js +1 -1
- package/dist/hr/mod.js.map +1 -1
- package/dist/hr/vat.d.ts +3 -6
- package/dist/hr/vat.js +9 -44
- package/dist/hr/vat.js.map +1 -1
- package/dist/hu/mod.d.ts +0 -2
- package/dist/hu/mod.js +1 -1
- package/dist/hu/mod.js.map +1 -1
- package/dist/hu/vat.d.ts +3 -6
- package/dist/hu/vat.js +9 -57
- package/dist/hu/vat.js.map +1 -1
- package/dist/iban.d.ts +3 -8
- package/dist/iban.js +9 -272
- package/dist/iban.js.map +1 -1
- package/dist/id/mod.d.ts +0 -2
- package/dist/id/mod.js +1 -1
- package/dist/id/mod.js.map +1 -1
- package/dist/id/npwp.d.ts +3 -6
- package/dist/id/npwp.js +9 -119
- package/dist/id/npwp.js.map +1 -1
- package/dist/ie/mod.d.ts +0 -2
- package/dist/ie/mod.js +2 -2
- package/dist/ie/mod.js.map +1 -1
- package/dist/ie/pps.d.ts +3 -6
- package/dist/ie/pps.js +9 -56
- package/dist/ie/pps.js.map +1 -1
- package/dist/ie/vat.d.ts +3 -6
- package/dist/ie/vat.js +9 -71
- package/dist/ie/vat.js.map +1 -1
- package/dist/il/idnr.d.ts +3 -6
- package/dist/il/idnr.js +9 -50
- package/dist/il/idnr.js.map +1 -1
- package/dist/il/mod.d.ts +0 -2
- package/dist/il/mod.js +1 -1
- package/dist/il/mod.js.map +1 -1
- package/dist/in/aadhaar.d.ts +3 -6
- package/dist/in/aadhaar.js +9 -47
- package/dist/in/aadhaar.js.map +1 -1
- package/dist/in/gstin.d.ts +3 -6
- package/dist/in/gstin.js +9 -119
- package/dist/in/gstin.js.map +1 -1
- package/dist/in/mod.d.ts +0 -2
- package/dist/in/mod.js +1 -1
- package/dist/in/mod.js.map +1 -1
- package/dist/in/pan.d.ts +4 -20
- package/dist/in/pan.js +9 -42
- package/dist/in/pan.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +2 -2
- package/dist/iq/mod.d.ts +0 -2
- package/dist/iq/mod.js +1 -1
- package/dist/iq/mod.js.map +1 -1
- package/dist/iq/nid.d.ts +4 -22
- package/dist/iq/nid.js +9 -39
- package/dist/iq/nid.js.map +1 -1
- package/dist/ir/mod.d.ts +0 -2
- package/dist/ir/mod.js +1 -1
- package/dist/ir/mod.js.map +1 -1
- package/dist/ir/nid.d.ts +3 -10
- package/dist/ir/nid.js +9 -64
- package/dist/ir/nid.js.map +1 -1
- package/dist/is/kennitala.d.ts +3 -6
- package/dist/is/kennitala.js +9 -77
- package/dist/is/kennitala.js.map +1 -1
- package/dist/is/mod.d.ts +0 -2
- package/dist/is/mod.js +1 -1
- package/dist/is/mod.js.map +1 -1
- package/dist/is/vsk.d.ts +4 -14
- package/dist/is/vsk.js +9 -37
- package/dist/is/vsk.js.map +1 -1
- package/dist/isin.d.ts +3 -6
- package/dist/isin.js +9 -71
- package/dist/isin.js.map +1 -1
- package/dist/it/codicefiscale.d.ts +5 -13
- package/dist/it/codicefiscale.js +10 -214
- package/dist/it/codicefiscale.js.map +1 -1
- package/dist/it/iva.d.ts +3 -6
- package/dist/it/iva.js +9 -60
- package/dist/it/iva.js.map +1 -1
- package/dist/it/mod.d.ts +0 -2
- package/dist/it/mod.js +2 -2
- package/dist/it/mod.js.map +1 -1
- package/dist/jp/cn.d.ts +3 -6
- package/dist/jp/cn.js +9 -56
- package/dist/jp/cn.js.map +1 -1
- package/dist/jp/mod.d.ts +0 -2
- package/dist/jp/mod.js +1 -1
- package/dist/jp/mod.js.map +1 -1
- package/dist/jp/mynumber.d.ts +3 -6
- package/dist/jp/mynumber.js +9 -73
- package/dist/jp/mynumber.js.map +1 -1
- package/dist/kr/brn.d.ts +4 -16
- package/dist/kr/brn.js +9 -55
- package/dist/kr/brn.js.map +1 -1
- package/dist/kr/mod.d.ts +0 -2
- package/dist/kr/mod.js +1 -1
- package/dist/kr/mod.js.map +1 -1
- package/dist/kr/rrn.d.ts +5 -17
- package/dist/kr/rrn.js +10 -131
- package/dist/kr/rrn.js.map +1 -1
- package/dist/kw/civil.d.ts +5 -13
- package/dist/kw/civil.js +10 -98
- package/dist/kw/civil.js.map +1 -1
- package/dist/kw/mod.d.ts +0 -2
- package/dist/kw/mod.js +1 -1
- package/dist/kw/mod.js.map +1 -1
- package/dist/kz/iin.d.ts +5 -16
- package/dist/kz/iin.js +10 -132
- package/dist/kz/iin.js.map +1 -1
- package/dist/kz/mod.d.ts +0 -2
- package/dist/kz/mod.js +1 -1
- package/dist/kz/mod.js.map +1 -1
- package/dist/lei.d.ts +3 -6
- package/dist/lei.js +9 -55
- package/dist/lei.js.map +1 -1
- package/dist/li/mod.d.ts +0 -2
- package/dist/li/mod.js +1 -1
- package/dist/li/mod.js.map +1 -1
- package/dist/li/peid.d.ts +4 -16
- package/dist/li/peid.js +9 -49
- package/dist/li/peid.js.map +1 -1
- package/dist/lk/mod.d.ts +0 -2
- package/dist/lk/mod.js +1 -1
- package/dist/lk/mod.js.map +1 -1
- package/dist/lk/nic.d.ts +5 -12
- package/dist/lk/nic.js +10 -135
- package/dist/lk/nic.js.map +1 -1
- package/dist/lt/asmens.d.ts +3 -6
- package/dist/lt/asmens.js +9 -78
- package/dist/lt/asmens.js.map +1 -1
- package/dist/lt/mod.d.ts +0 -2
- package/dist/lt/mod.js +2 -2
- package/dist/lt/mod.js.map +1 -1
- package/dist/lt/vat.d.ts +3 -6
- package/dist/lt/vat.js +9 -60
- package/dist/lt/vat.js.map +1 -1
- package/dist/lu/mod.d.ts +0 -2
- package/dist/lu/mod.js +1 -1
- package/dist/lu/mod.js.map +1 -1
- package/dist/lu/vat.d.ts +3 -6
- package/dist/lu/vat.js +9 -46
- package/dist/lu/vat.js.map +1 -1
- package/dist/luhn.d.ts +3 -9
- package/dist/luhn.js +7 -47
- package/dist/luhn.js.map +1 -1
- package/dist/lv/mod.d.ts +0 -2
- package/dist/lv/mod.js +1 -1
- package/dist/lv/mod.js.map +1 -1
- package/dist/lv/vat.d.ts +3 -6
- package/dist/lv/vat.js +9 -101
- package/dist/lv/vat.js.map +1 -1
- package/dist/ma/ice.d.ts +3 -6
- package/dist/ma/ice.js +9 -44
- package/dist/ma/ice.js.map +1 -1
- package/dist/ma/mod.d.ts +0 -2
- package/dist/ma/mod.js +1 -1
- package/dist/ma/mod.js.map +1 -1
- package/dist/mc/mod.d.ts +0 -2
- package/dist/mc/mod.js +1 -1
- package/dist/mc/mod.js.map +1 -1
- package/dist/mc/tva.d.ts +3 -6
- package/dist/mc/tva.js +9 -50
- package/dist/mc/tva.js.map +1 -1
- package/dist/md/idno.d.ts +3 -5
- package/dist/md/idno.js +6 -58
- package/dist/md/idno.js.map +1 -1
- package/dist/md/mod.d.ts +0 -2
- package/dist/md/mod.js +1 -1
- package/dist/md/mod.js.map +1 -1
- package/dist/me/mod.d.ts +0 -2
- package/dist/me/mod.js +1 -1
- package/dist/me/mod.js.map +1 -1
- package/dist/me/pib.d.ts +3 -6
- package/dist/me/pib.js +9 -51
- package/dist/me/pib.js.map +1 -1
- package/dist/metadata.d.ts +3505 -0
- package/dist/metadata.js +4949 -0
- package/dist/metadata.js.map +1 -0
- package/dist/mk/edb.d.ts +3 -6
- package/dist/mk/edb.js +9 -64
- package/dist/mk/edb.js.map +1 -1
- package/dist/mk/mod.d.ts +0 -2
- package/dist/mk/mod.js +1 -1
- package/dist/mk/mod.js.map +1 -1
- package/dist/mt/mod.d.ts +0 -2
- package/dist/mt/mod.js +1 -1
- package/dist/mt/mod.js.map +1 -1
- package/dist/mt/vat.d.ts +3 -6
- package/dist/mt/vat.js +9 -58
- package/dist/mt/vat.js.map +1 -1
- package/dist/mu/brn.d.ts +4 -28
- package/dist/mu/brn.js +9 -44
- package/dist/mu/brn.js.map +1 -1
- package/dist/mu/mod.d.ts +0 -2
- package/dist/mu/mod.js +1 -1
- package/dist/mu/mod.js.map +1 -1
- package/dist/mx/clabe.d.ts +3 -10
- package/dist/mx/clabe.js +9 -70
- package/dist/mx/clabe.js.map +1 -1
- package/dist/mx/curp.d.ts +5 -16
- package/dist/mx/curp.js +10 -144
- package/dist/mx/curp.js.map +1 -1
- package/dist/mx/mod.d.ts +0 -2
- package/dist/mx/mod.js +1 -1
- package/dist/mx/mod.js.map +1 -1
- package/dist/mx/rfc.d.ts +3 -10
- package/dist/mx/rfc.js +9 -91
- package/dist/mx/rfc.js.map +1 -1
- package/dist/my/mod.d.ts +0 -2
- package/dist/my/mod.js +1 -1
- package/dist/my/mod.js.map +1 -1
- package/dist/my/nric.d.ts +5 -12
- package/dist/my/nric.js +10 -184
- package/dist/my/nric.js.map +1 -1
- package/dist/native-node.d.ts +14 -0
- package/dist/native-node.js +75 -0
- package/dist/native-node.js.map +1 -0
- package/dist/native.d.ts +79 -0
- package/dist/native.js +24 -0
- package/dist/native.js.map +1 -0
- package/dist/ng/mod.d.ts +0 -2
- package/dist/ng/mod.js +1 -1
- package/dist/ng/mod.js.map +1 -1
- package/dist/ng/nin.d.ts +4 -18
- package/dist/ng/nin.js +9 -40
- package/dist/ng/nin.js.map +1 -1
- package/dist/ni/mod.d.ts +0 -2
- package/dist/ni/mod.js +1 -1
- package/dist/ni/mod.js.map +1 -1
- package/dist/ni/ruc.d.ts +3 -15
- package/dist/ni/ruc.js +9 -87
- package/dist/ni/ruc.js.map +1 -1
- package/dist/nl/bsn.d.ts +3 -6
- package/dist/nl/bsn.js +9 -58
- package/dist/nl/bsn.js.map +1 -1
- package/dist/nl/kvk.d.ts +4 -14
- package/dist/nl/kvk.js +9 -35
- package/dist/nl/kvk.js.map +1 -1
- package/dist/nl/mod.d.ts +0 -2
- package/dist/nl/mod.js +2 -2
- package/dist/nl/mod.js.map +1 -1
- package/dist/nl/vat.d.ts +3 -6
- package/dist/nl/vat.js +9 -44
- package/dist/nl/vat.js.map +1 -1
- package/dist/no/fodselsnummer.d.ts +5 -13
- package/dist/no/fodselsnummer.js +10 -123
- package/dist/no/fodselsnummer.js.map +1 -1
- package/dist/no/mod.d.ts +2 -4
- package/dist/no/mod.js +3 -3
- package/dist/no/mod.js.map +1 -1
- package/dist/no/mva.d.ts +3 -6
- package/dist/no/mva.js +9 -43
- package/dist/no/mva.js.map +1 -1
- package/dist/no/orgnr.d.ts +3 -6
- package/dist/no/orgnr.js +9 -56
- package/dist/no/orgnr.js.map +1 -1
- package/dist/nz/ird.d.ts +3 -6
- package/dist/nz/ird.js +9 -92
- package/dist/nz/ird.js.map +1 -1
- package/dist/nz/mod.d.ts +0 -2
- package/dist/nz/mod.js +1 -1
- package/dist/nz/mod.js.map +1 -1
- package/dist/pa/mod.d.ts +0 -2
- package/dist/pa/mod.js +1 -1
- package/dist/pa/mod.js.map +1 -1
- package/dist/pa/ruc.d.ts +3 -15
- package/dist/pa/ruc.js +9 -181
- package/dist/pa/ruc.js.map +1 -1
- package/dist/patterns.d.ts +6 -35
- package/dist/patterns.js +10 -171
- package/dist/patterns.js.map +1 -1
- package/dist/pe/mod.d.ts +0 -2
- package/dist/pe/mod.js +1 -1
- package/dist/pe/mod.js.map +1 -1
- package/dist/pe/ruc.d.ts +3 -11
- package/dist/pe/ruc.js +9 -91
- package/dist/pe/ruc.js.map +1 -1
- package/dist/ph/mod.d.ts +0 -2
- package/dist/ph/mod.js +1 -1
- package/dist/ph/mod.js.map +1 -1
- package/dist/ph/philid.d.ts +4 -19
- package/dist/ph/philid.js +9 -45
- package/dist/ph/philid.js.map +1 -1
- package/dist/pk/cnic.d.ts +4 -19
- package/dist/pk/cnic.js +9 -54
- package/dist/pk/cnic.js.map +1 -1
- package/dist/pk/mod.d.ts +0 -2
- package/dist/pk/mod.js +1 -1
- package/dist/pk/mod.js.map +1 -1
- package/dist/pl/mod.d.ts +0 -2
- package/dist/pl/mod.js +1 -1
- package/dist/pl/mod.js.map +1 -1
- package/dist/pl/nip.d.ts +3 -10
- package/dist/pl/nip.js +9 -65
- package/dist/pl/nip.js.map +1 -1
- package/dist/pl/pesel.d.ts +5 -12
- package/dist/pl/pesel.js +10 -96
- package/dist/pl/pesel.js.map +1 -1
- package/dist/pl/regon.d.ts +3 -6
- package/dist/pl/regon.js +9 -72
- package/dist/pl/regon.js.map +1 -1
- package/dist/pt/cc.d.ts +3 -6
- package/dist/pt/cc.js +9 -67
- package/dist/pt/cc.js.map +1 -1
- package/dist/pt/mod.d.ts +0 -2
- package/dist/pt/mod.js +2 -2
- package/dist/pt/mod.js.map +1 -1
- package/dist/pt/vat.d.ts +3 -6
- package/dist/pt/vat.js +9 -61
- package/dist/pt/vat.js.map +1 -1
- package/dist/registry.d.ts +6 -0
- package/dist/registry.js +357 -0
- package/dist/registry.js.map +1 -0
- package/dist/ro/cnp.d.ts +5 -12
- package/dist/ro/cnp.js +10 -163
- package/dist/ro/cnp.js.map +1 -1
- package/dist/ro/mod.d.ts +0 -2
- package/dist/ro/mod.js +2 -2
- package/dist/ro/mod.js.map +1 -1
- package/dist/ro/vat.d.ts +3 -6
- package/dist/ro/vat.js +9 -74
- package/dist/ro/vat.js.map +1 -1
- package/dist/rs/mod.d.ts +0 -2
- package/dist/rs/mod.js +1 -1
- package/dist/rs/mod.js.map +1 -1
- package/dist/rs/pib.d.ts +3 -6
- package/dist/rs/pib.js +9 -48
- package/dist/rs/pib.js.map +1 -1
- package/dist/ru/inn.d.ts +3 -6
- package/dist/ru/inn.js +9 -89
- package/dist/ru/inn.js.map +1 -1
- package/dist/ru/mod.d.ts +0 -2
- package/dist/ru/mod.js +1 -1
- package/dist/ru/mod.js.map +1 -1
- package/dist/runtime.js +121 -0
- package/dist/runtime.js.map +1 -0
- package/dist/se/mod.d.ts +0 -2
- package/dist/se/mod.js +2 -2
- package/dist/se/mod.js.map +1 -1
- package/dist/se/orgnr.d.ts +3 -6
- package/dist/se/orgnr.js +9 -48
- package/dist/se/orgnr.js.map +1 -1
- package/dist/se/personnummer.d.ts +5 -16
- package/dist/se/personnummer.js +10 -111
- package/dist/se/personnummer.js.map +1 -1
- package/dist/se/vat.d.ts +3 -6
- package/dist/se/vat.js +9 -52
- package/dist/se/vat.js.map +1 -1
- package/dist/sg/mod.d.ts +0 -2
- package/dist/sg/mod.js +1 -1
- package/dist/sg/mod.js.map +1 -1
- package/dist/sg/uen.d.ts +3 -6
- package/dist/sg/uen.js +9 -180
- package/dist/sg/uen.js.map +1 -1
- package/dist/si/emso.d.ts +5 -12
- package/dist/si/emso.js +10 -102
- package/dist/si/emso.js.map +1 -1
- package/dist/si/mod.d.ts +0 -2
- package/dist/si/mod.js +2 -2
- package/dist/si/mod.js.map +1 -1
- package/dist/si/vat.d.ts +3 -6
- package/dist/si/vat.js +9 -61
- package/dist/si/vat.js.map +1 -1
- package/dist/sk/dic.d.ts +3 -6
- package/dist/sk/dic.js +9 -63
- package/dist/sk/dic.js.map +1 -1
- package/dist/sk/ico.d.ts +6 -5
- package/dist/sk/ico.js +9 -27
- package/dist/sk/ico.js.map +1 -1
- package/dist/sk/mod.d.ts +0 -2
- package/dist/sk/mod.js +1 -1
- package/dist/sk/mod.js.map +1 -1
- package/dist/sk/rc.d.ts +7 -5
- package/dist/sk/rc.js +10 -30
- package/dist/sk/rc.js.map +1 -1
- package/dist/th/mod.d.ts +0 -2
- package/dist/th/mod.js +1 -1
- package/dist/th/mod.js.map +1 -1
- package/dist/th/tin.d.ts +3 -6
- package/dist/th/tin.js +9 -49
- package/dist/th/tin.js.map +1 -1
- package/dist/tr/mod.d.ts +0 -2
- package/dist/tr/mod.js +1 -1
- package/dist/tr/mod.js.map +1 -1
- package/dist/tr/tckimlik.d.ts +3 -7
- package/dist/tr/tckimlik.js +9 -56
- package/dist/tr/tckimlik.js.map +1 -1
- package/dist/tr/vkn.d.ts +3 -7
- package/dist/tr/vkn.js +9 -56
- package/dist/tr/vkn.js.map +1 -1
- package/dist/tw/mod.d.ts +0 -2
- package/dist/tw/mod.js +1 -1
- package/dist/tw/mod.js.map +1 -1
- package/dist/tw/ubn.d.ts +3 -6
- package/dist/tw/ubn.js +9 -72
- package/dist/tw/ubn.js.map +1 -1
- package/dist/types.d.ts +16 -85
- package/dist/ua/edrpou.d.ts +3 -6
- package/dist/ua/edrpou.js +9 -92
- package/dist/ua/edrpou.js.map +1 -1
- package/dist/ua/mod.d.ts +0 -2
- package/dist/ua/mod.js +1 -1
- package/dist/ua/mod.js.map +1 -1
- package/dist/us/ein.d.ts +4 -17
- package/dist/us/ein.js +9 -221
- package/dist/us/ein.js.map +1 -1
- package/dist/us/itin.d.ts +4 -20
- package/dist/us/itin.js +9 -54
- package/dist/us/itin.js.map +1 -1
- package/dist/us/mod.d.ts +0 -2
- package/dist/us/mod.js +1 -1
- package/dist/us/mod.js.map +1 -1
- package/dist/us/rtn.d.ts +3 -6
- package/dist/us/rtn.js +9 -75
- package/dist/us/rtn.js.map +1 -1
- package/dist/us/ssn.d.ts +4 -18
- package/dist/us/ssn.js +9 -63
- package/dist/us/ssn.js.map +1 -1
- package/dist/uy/mod.d.ts +0 -2
- package/dist/uy/mod.js +1 -1
- package/dist/uy/mod.js.map +1 -1
- package/dist/uy/rut.d.ts +3 -10
- package/dist/uy/rut.js +9 -88
- package/dist/uy/rut.js.map +1 -1
- package/dist/ve/mod.d.ts +0 -2
- package/dist/ve/mod.js +1 -1
- package/dist/ve/mod.js.map +1 -1
- package/dist/ve/rif.d.ts +3 -10
- package/dist/ve/rif.js +9 -92
- package/dist/ve/rif.js.map +1 -1
- package/dist/vn/mod.d.ts +0 -2
- package/dist/vn/mod.js +1 -1
- package/dist/vn/mod.js.map +1 -1
- package/dist/vn/mst.d.ts +3 -6
- package/dist/vn/mst.js +9 -67
- package/dist/vn/mst.js.map +1 -1
- package/dist/za/idnr.d.ts +5 -12
- package/dist/za/idnr.js +10 -94
- package/dist/za/idnr.js.map +1 -1
- package/dist/za/mod.d.ts +0 -2
- package/dist/za/mod.js +1 -1
- package/dist/za/mod.js.map +1 -1
- package/index.cjs +3 -0
- package/package.json +38 -62
- package/registry.json +4829 -0
- package/registry.schema.json +94 -0
- package/LICENSE +0 -21
- package/README.md +0 -346
- package/dist/_checksums/keccak.d.ts +0 -5
- package/dist/_checksums/keccak.js +0 -118
- package/dist/_checksums/keccak.js.map +0 -1
- package/dist/_checksums/luhn.d.ts +0 -12
- package/dist/_checksums/luhn.js +0 -26
- package/dist/_checksums/luhn.js.map +0 -1
- package/dist/_checksums/mod1110.d.ts +0 -12
- package/dist/_checksums/mod1110.js +0 -25
- package/dist/_checksums/mod1110.js.map +0 -1
- package/dist/_checksums/mod112.d.ts +0 -24
- package/dist/_checksums/mod112.js +0 -53
- package/dist/_checksums/mod112.js.map +0 -1
- package/dist/_checksums/mod97.d.ts +0 -23
- package/dist/_checksums/mod97.js +0 -28
- package/dist/_checksums/mod97.js.map +0 -1
- package/dist/_checksums/sha256.d.ts +0 -5
- package/dist/_checksums/sha256.js +0 -164
- package/dist/_checksums/sha256.js.map +0 -1
- package/dist/_checksums/verhoeff.d.ts +0 -22
- package/dist/_checksums/verhoeff.js +0 -271
- package/dist/_checksums/verhoeff.js.map +0 -1
- package/dist/_checksums/weighted-sum.d.ts +0 -13
- package/dist/_checksums/weighted-sum.js +0 -22
- package/dist/_checksums/weighted-sum.js.map +0 -1
- package/dist/_util/arabic.d.ts +0 -19
- package/dist/_util/arabic.js +0 -41
- package/dist/_util/arabic.js.map +0 -1
- package/dist/_util/clean.d.ts +0 -18
- package/dist/_util/clean.js +0 -76
- package/dist/_util/clean.js.map +0 -1
- package/dist/_util/date.d.ts +0 -12
- package/dist/_util/date.js +0 -19
- package/dist/_util/date.js.map +0 -1
- package/dist/_util/generate.d.ts +0 -28
- package/dist/_util/generate.js +0 -43
- package/dist/_util/generate.js.map +0 -1
- package/dist/_util/result.d.ts +0 -8
- package/dist/_util/result.js +0 -13
- package/dist/_util/result.js.map +0 -1
- package/dist/_util/strings.d.ts +0 -21
- package/dist/_util/strings.js +0 -28
- package/dist/_util/strings.js.map +0 -1
- package/src/_checksums/keccak.ts +0 -145
- package/src/_checksums/luhn.ts +0 -24
- package/src/_checksums/mod1110.ts +0 -24
- package/src/_checksums/mod112.ts +0 -41
- package/src/_checksums/mod97.ts +0 -28
- package/src/_checksums/sha256.ts +0 -125
- package/src/_checksums/verhoeff.ts +0 -71
- package/src/_checksums/weighted-sum.ts +0 -23
- package/src/_util/arabic.ts +0 -48
- package/src/_util/clean.ts +0 -91
- package/src/_util/date.ts +0 -23
- package/src/_util/generate.ts +0 -62
- package/src/_util/result.ts +0 -10
- package/src/_util/strings.ts +0 -32
- package/src/ad/mod.ts +0 -1
- package/src/ad/nrt.ts +0 -123
- package/src/ae/eid.ts +0 -110
- package/src/ae/mod.ts +0 -1
- package/src/ai/mod.ts +0 -1
- package/src/ai/tin.ts +0 -102
- package/src/al/mod.ts +0 -1
- package/src/al/nipt.ts +0 -82
- package/src/am/mod.ts +0 -1
- package/src/am/tin.ts +0 -77
- package/src/ar/cbu.ts +0 -110
- package/src/ar/cuit.ts +0 -149
- package/src/ar/dni.ts +0 -83
- package/src/ar/mod.ts +0 -3
- package/src/at/businessid.ts +0 -78
- package/src/at/mod.ts +0 -4
- package/src/at/tin.ts +0 -94
- package/src/at/uid.ts +0 -96
- package/src/at/vnr.ts +0 -161
- package/src/au/abn.ts +0 -89
- package/src/au/acn.ts +0 -90
- package/src/au/mod.ts +0 -3
- package/src/au/tfn.ts +0 -89
- package/src/az/mod.ts +0 -1
- package/src/az/voen.ts +0 -131
- package/src/ba/jmbg.ts +0 -130
- package/src/ba/mod.ts +0 -1
- package/src/bd/mod.ts +0 -1
- package/src/bd/nid.ts +0 -143
- package/src/be/bis.ts +0 -109
- package/src/be/mod.ts +0 -3
- package/src/be/nn.ts +0 -129
- package/src/be/vat.ts +0 -111
- package/src/bg/egn.ts +0 -164
- package/src/bg/mod.ts +0 -3
- package/src/bg/pnf.ts +0 -90
- package/src/bg/vat.ts +0 -160
- package/src/bh/cpr.ts +0 -94
- package/src/bh/mod.ts +0 -1
- package/src/bic.ts +0 -105
- package/src/br/cnpj.ts +0 -156
- package/src/br/cpf.ts +0 -118
- package/src/br/mod.ts +0 -2
- package/src/by/mod.ts +0 -1
- package/src/by/unp.ts +0 -163
- package/src/bz/mod.ts +0 -1
- package/src/bz/tin.ts +0 -122
- package/src/ca/bn.ts +0 -111
- package/src/ca/mod.ts +0 -2
- package/src/ca/sin.ts +0 -95
- package/src/ch/mod.ts +0 -3
- package/src/ch/ssn.ts +0 -99
- package/src/ch/uid.ts +0 -112
- package/src/ch/vat.ts +0 -89
- package/src/cl/mod.ts +0 -1
- package/src/cl/rut.ts +0 -124
- package/src/cn/mod.ts +0 -2
- package/src/cn/ric.ts +0 -184
- package/src/cn/uscc.ts +0 -127
- package/src/co/mod.ts +0 -1
- package/src/co/nit.ts +0 -116
- package/src/cr/cpf.ts +0 -116
- package/src/cr/mod.ts +0 -1
- package/src/creditcard.ts +0 -194
- package/src/crypto/btcbase58.ts +0 -144
- package/src/crypto/btcbech32.ts +0 -210
- package/src/crypto/eth.ts +0 -114
- package/src/crypto/mod.ts +0 -4
- package/src/crypto/wallet.ts +0 -67
- package/src/cu/mod.ts +0 -1
- package/src/cu/ni.ts +0 -146
- package/src/cy/mod.ts +0 -1
- package/src/cy/vat.ts +0 -134
- package/src/cz/dic.ts +0 -140
- package/src/cz/ico.ts +0 -86
- package/src/cz/mod.ts +0 -3
- package/src/cz/rc.ts +0 -222
- package/src/de/handelsreg.ts +0 -122
- package/src/de/idnr.ts +0 -147
- package/src/de/mod.ts +0 -5
- package/src/de/stnr.ts +0 -222
- package/src/de/svnr.ts +0 -171
- package/src/de/vat.ts +0 -102
- package/src/dk/cpr.ts +0 -137
- package/src/dk/cvr.ts +0 -91
- package/src/dk/mod.ts +0 -3
- package/src/dk/vat.ts +0 -96
- package/src/do/mod.ts +0 -1
- package/src/do/rnc.ts +0 -130
- package/src/ec/mod.ts +0 -1
- package/src/ec/ruc.ts +0 -199
- package/src/ee/ik.ts +0 -167
- package/src/ee/mod.ts +0 -3
- package/src/ee/registrikood.ts +0 -86
- package/src/ee/vat.ts +0 -89
- package/src/eg/mod.ts +0 -1
- package/src/eg/tn.ts +0 -107
- package/src/es/cif.ts +0 -108
- package/src/es/dni.ts +0 -94
- package/src/es/mod.ts +0 -5
- package/src/es/nie.ts +0 -111
- package/src/es/nss.ts +0 -113
- package/src/es/vat.ts +0 -186
- package/src/eu/mod.ts +0 -1
- package/src/eu/vat.ts +0 -220
- package/src/fi/hetu.ts +0 -200
- package/src/fi/mod.ts +0 -3
- package/src/fi/vat.ts +0 -87
- package/src/fi/ytunnus.ts +0 -87
- package/src/fr/mod.ts +0 -5
- package/src/fr/nif.ts +0 -97
- package/src/fr/nir.ts +0 -197
- package/src/fr/siren.ts +0 -83
- package/src/fr/siret.ts +0 -126
- package/src/fr/tva.ts +0 -150
- package/src/gb/mod.ts +0 -5
- package/src/gb/nhs.ts +0 -92
- package/src/gb/nino.ts +0 -158
- package/src/gb/sedol.ts +0 -143
- package/src/gb/utr.ts +0 -85
- package/src/gb/vat.ts +0 -162
- package/src/ge/mod.ts +0 -1
- package/src/ge/pin.ts +0 -75
- package/src/gh/mod.ts +0 -1
- package/src/gh/tin.ts +0 -105
- package/src/gr/amka.ts +0 -108
- package/src/gr/mod.ts +0 -2
- package/src/gr/vat.ts +0 -100
- package/src/gt/mod.ts +0 -1
- package/src/gt/nit.ts +0 -123
- package/src/hk/hkid.ts +0 -136
- package/src/hk/mod.ts +0 -1
- package/src/hr/mod.ts +0 -1
- package/src/hr/vat.ts +0 -83
- package/src/hu/mod.ts +0 -1
- package/src/hu/vat.ts +0 -87
- package/src/iban.ts +0 -344
- package/src/id/mod.ts +0 -1
- package/src/id/npwp.ts +0 -191
- package/src/ie/mod.ts +0 -2
- package/src/ie/pps.ts +0 -109
- package/src/ie/vat.ts +0 -142
- package/src/il/idnr.ts +0 -91
- package/src/il/mod.ts +0 -1
- package/src/in/aadhaar.ts +0 -100
- package/src/in/gstin.ts +0 -175
- package/src/in/mod.ts +0 -3
- package/src/in/pan.ts +0 -97
- package/src/index.ts +0 -123
- package/src/iq/mod.ts +0 -1
- package/src/iq/nid.ts +0 -75
- package/src/ir/mod.ts +0 -1
- package/src/ir/nid.ts +0 -124
- package/src/is/kennitala.ts +0 -129
- package/src/is/mod.ts +0 -2
- package/src/is/vsk.ts +0 -67
- package/src/isin.ts +0 -124
- package/src/it/codicefiscale.ts +0 -332
- package/src/it/iva.ts +0 -119
- package/src/it/mod.ts +0 -2
- package/src/jp/cn.ts +0 -95
- package/src/jp/mod.ts +0 -2
- package/src/jp/mynumber.ts +0 -107
- package/src/kr/brn.ts +0 -105
- package/src/kr/mod.ts +0 -2
- package/src/kr/rrn.ts +0 -189
- package/src/kw/civil.ts +0 -161
- package/src/kw/mod.ts +0 -1
- package/src/kz/iin.ts +0 -184
- package/src/kz/mod.ts +0 -1
- package/src/lei.ts +0 -102
- package/src/li/mod.ts +0 -1
- package/src/li/peid.ts +0 -70
- package/src/lk/mod.ts +0 -1
- package/src/lk/nic.ts +0 -233
- package/src/lt/asmens.ts +0 -124
- package/src/lt/mod.ts +0 -2
- package/src/lt/vat.ts +0 -114
- package/src/lu/mod.ts +0 -1
- package/src/lu/vat.ts +0 -85
- package/src/luhn.ts +0 -79
- package/src/lv/mod.ts +0 -1
- package/src/lv/vat.ts +0 -169
- package/src/ma/ice.ts +0 -83
- package/src/ma/mod.ts +0 -1
- package/src/mc/mod.ts +0 -1
- package/src/mc/tva.ts +0 -78
- package/src/md/idno.ts +0 -90
- package/src/md/mod.ts +0 -1
- package/src/me/mod.ts +0 -1
- package/src/me/pib.ts +0 -83
- package/src/mk/edb.ts +0 -95
- package/src/mk/mod.ts +0 -1
- package/src/mt/mod.ts +0 -1
- package/src/mt/vat.ts +0 -93
- package/src/mu/brn.ts +0 -106
- package/src/mu/mod.ts +0 -1
- package/src/mx/clabe.ts +0 -115
- package/src/mx/curp.ts +0 -247
- package/src/mx/mod.ts +0 -3
- package/src/mx/rfc.ts +0 -179
- package/src/my/mod.ts +0 -1
- package/src/my/nric.ts +0 -260
- package/src/ng/mod.ts +0 -1
- package/src/ng/nin.ts +0 -76
- package/src/ni/mod.ts +0 -1
- package/src/ni/ruc.ts +0 -180
- package/src/nl/bsn.ts +0 -91
- package/src/nl/kvk.ts +0 -63
- package/src/nl/mod.ts +0 -3
- package/src/nl/vat.ts +0 -95
- package/src/no/fodselsnummer.ts +0 -197
- package/src/no/mod.ts +0 -3
- package/src/no/mva.ts +0 -77
- package/src/no/orgnr.ts +0 -83
- package/src/nz/ird.ts +0 -132
- package/src/nz/mod.ts +0 -1
- package/src/pa/mod.ts +0 -1
- package/src/pa/ruc.ts +0 -387
- package/src/patterns.ts +0 -390
- package/src/pe/mod.ts +0 -1
- package/src/pe/ruc.ts +0 -124
- package/src/ph/mod.ts +0 -1
- package/src/ph/philid.ts +0 -80
- package/src/pk/cnic.ts +0 -109
- package/src/pk/mod.ts +0 -1
- package/src/pl/mod.ts +0 -3
- package/src/pl/nip.ts +0 -100
- package/src/pl/pesel.ts +0 -155
- package/src/pl/regon.ts +0 -102
- package/src/pt/cc.ts +0 -112
- package/src/pt/mod.ts +0 -2
- package/src/pt/vat.ts +0 -98
- package/src/ro/cnp.ts +0 -179
- package/src/ro/mod.ts +0 -2
- package/src/ro/vat.ts +0 -99
- package/src/rs/mod.ts +0 -1
- package/src/rs/pib.ts +0 -87
- package/src/ru/inn.ts +0 -113
- package/src/ru/mod.ts +0 -1
- package/src/se/mod.ts +0 -3
- package/src/se/orgnr.ts +0 -85
- package/src/se/personnummer.ts +0 -183
- package/src/se/vat.ts +0 -97
- package/src/sg/mod.ts +0 -1
- package/src/sg/uen.ts +0 -288
- package/src/si/emso.ts +0 -178
- package/src/si/mod.ts +0 -2
- package/src/si/vat.ts +0 -113
- package/src/sk/dic.ts +0 -110
- package/src/sk/ico.ts +0 -40
- package/src/sk/mod.ts +0 -3
- package/src/sk/rc.ts +0 -44
- package/src/th/mod.ts +0 -1
- package/src/th/tin.ts +0 -106
- package/src/tr/mod.ts +0 -2
- package/src/tr/tckimlik.ts +0 -115
- package/src/tr/vkn.ts +0 -101
- package/src/tw/mod.ts +0 -1
- package/src/tw/ubn.ts +0 -112
- package/src/types.ts +0 -262
- package/src/ua/edrpou.ts +0 -108
- package/src/ua/mod.ts +0 -1
- package/src/us/ein.ts +0 -261
- package/src/us/itin.ts +0 -129
- package/src/us/mod.ts +0 -4
- package/src/us/rtn.ts +0 -139
- package/src/us/ssn.ts +0 -121
- package/src/uy/mod.ts +0 -1
- package/src/uy/rut.ts +0 -150
- package/src/ve/mod.ts +0 -1
- package/src/ve/rif.ts +0 -147
- package/src/vn/mod.ts +0 -1
- package/src/vn/mst.ts +0 -132
- package/src/za/idnr.ts +0 -159
- package/src/za/mod.ts +0 -1
package/dist/nz/ird.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ird.js","names":[],"sources":["../../src/nz/ird.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ird.js","names":[],"sources":["../../src/generated/nz/ird.ts"],"sourcesContent":["// Generated by scripts/generate-public-surface.ts. Do not edit.\nimport { createValidator } from \"../../runtime\";\nimport type { CountryValidator } from \"../../types\";\n\nconst ird: CountryValidator<\"NZ\"> = createValidator(\n \"nz.ird\",\n 139,\n);\n\nexport default ird;\nexport const compact = ird.compact;\nexport const format = ird.format;\nexport const validate = ird.validate;\nexport const generate = (): string =>\n ird.generate?.() ??\n (() => {\n throw new Error(\n \"Validator nz.ird cannot generate values\",\n );\n })();\n"],"mappings":";;AAIA,MAAM,MAA8B,gBAClC,UACA,GACF;AAGA,MAAa,UAAU,IAAI;AAC3B,MAAa,SAAS,IAAI;AAC1B,MAAa,WAAW,IAAI;AAC5B,MAAa,iBACX,IAAI,WAAW,YACR;CACL,MAAM,IAAI,MACR,yCACF;AACF,EAAA,CAAG"}
|
package/dist/nz/mod.d.ts
CHANGED
package/dist/nz/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import ird from "./ird.js";
|
|
3
|
-
//#region src/nz/mod.ts
|
|
3
|
+
//#region src/generated/nz/mod.ts
|
|
4
4
|
var nz_exports = /* @__PURE__ */ __exportAll({ ird: () => ird });
|
|
5
5
|
//#endregion
|
|
6
6
|
export { ird, nz_exports };
|
package/dist/nz/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":[],"sources":["../../src/nz/mod.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../src/generated/nz/mod.ts"],"sourcesContent":["// Generated by scripts/generate-public-surface.ts. Do not edit.\nexport { default as ird } from \"./ird\";\n"],"mappings":""}
|
package/dist/pa/mod.d.ts
CHANGED
package/dist/pa/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import ruc from "./ruc.js";
|
|
3
|
-
//#region src/pa/mod.ts
|
|
3
|
+
//#region src/generated/pa/mod.ts
|
|
4
4
|
var pa_exports = /* @__PURE__ */ __exportAll({ ruc: () => ruc });
|
|
5
5
|
//#endregion
|
|
6
6
|
export { pa_exports, ruc };
|
package/dist/pa/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":[],"sources":["../../src/pa/mod.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../src/generated/pa/mod.ts"],"sourcesContent":["// Generated by scripts/generate-public-surface.ts. Do not edit.\nexport { default as ruc } from \"./ruc\";\n"],"mappings":""}
|
package/dist/pa/ruc.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import { CountryValidator, ValidateResult } from "../types.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Compact: normalize Unicode, collapse whitespace,
|
|
6
|
-
* strip colons around DV, and uppercase. Keeps
|
|
7
|
-
* hyphens (structural separators) and a single
|
|
8
|
-
* space before "DV".
|
|
9
|
-
*/
|
|
2
|
+
//#region src/generated/pa/ruc.d.ts
|
|
3
|
+
declare const ruc: CountryValidator<"PA">;
|
|
10
4
|
declare const compact: (value: string) => string;
|
|
11
|
-
declare const validate: (value: string) => ValidateResult;
|
|
12
|
-
/**
|
|
13
|
-
* Format: display as segments with " DV XX".
|
|
14
|
-
*/
|
|
15
5
|
declare const format: (value: string) => string;
|
|
16
|
-
|
|
6
|
+
declare const validate: (value: string) => ValidateResult;
|
|
17
7
|
declare const generate: () => string;
|
|
18
|
-
/** Panama tax identification number. */
|
|
19
|
-
declare const ruc: CountryValidator<"PA">;
|
|
20
8
|
//#endregion
|
|
21
9
|
export { compact, ruc as default, format, generate, validate };
|
|
22
10
|
//# sourceMappingURL=ruc.d.ts.map
|
package/dist/pa/ruc.js
CHANGED
|
@@ -1,184 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"00": "00",
|
|
11
|
-
"10": "01",
|
|
12
|
-
"11": "02",
|
|
13
|
-
"12": "03",
|
|
14
|
-
"13": "04",
|
|
15
|
-
"14": "05",
|
|
16
|
-
"15": "06",
|
|
17
|
-
"16": "07",
|
|
18
|
-
"17": "08",
|
|
19
|
-
"18": "09",
|
|
20
|
-
"19": "01",
|
|
21
|
-
"20": "02",
|
|
22
|
-
"21": "03",
|
|
23
|
-
"22": "04",
|
|
24
|
-
"23": "07",
|
|
25
|
-
"24": "08",
|
|
26
|
-
"25": "09",
|
|
27
|
-
"26": "02",
|
|
28
|
-
"27": "03",
|
|
29
|
-
"28": "04",
|
|
30
|
-
"29": "05",
|
|
31
|
-
"30": "06",
|
|
32
|
-
"31": "07",
|
|
33
|
-
"32": "08",
|
|
34
|
-
"33": "09",
|
|
35
|
-
"34": "01",
|
|
36
|
-
"35": "02",
|
|
37
|
-
"36": "03",
|
|
38
|
-
"37": "04",
|
|
39
|
-
"38": "05",
|
|
40
|
-
"39": "06",
|
|
41
|
-
"40": "07",
|
|
42
|
-
"41": "08",
|
|
43
|
-
"42": "09",
|
|
44
|
-
"43": "01",
|
|
45
|
-
"44": "02",
|
|
46
|
-
"45": "03",
|
|
47
|
-
"46": "04",
|
|
48
|
-
"47": "05",
|
|
49
|
-
"48": "06",
|
|
50
|
-
"49": "07"
|
|
51
|
-
};
|
|
52
|
-
/** Prepend n leading zeros. */
|
|
53
|
-
const z = (n) => "0".repeat(Math.max(0, n));
|
|
54
|
-
/**
|
|
55
|
-
* Compute a single DV digit via weighted sum mod 11.
|
|
56
|
-
* Weights start at 2 and increment, applied
|
|
57
|
-
* right-to-left. For old-format juridical RUCs,
|
|
58
|
-
* weight 12 is skipped (jumps from 11 to 13).
|
|
59
|
-
*/
|
|
60
|
-
const digitDV = (buf, isOldFormat) => {
|
|
61
|
-
let weight = 2;
|
|
62
|
-
let sum = 0;
|
|
63
|
-
for (let i = buf.length - 1; i >= 0; i--) {
|
|
64
|
-
if (isOldFormat && weight === 12) weight += 1;
|
|
65
|
-
sum += weight * (buf.charCodeAt(i) - 48);
|
|
66
|
-
weight += 1;
|
|
67
|
-
}
|
|
68
|
-
const r = sum % 11;
|
|
69
|
-
return r > 1 ? 11 - r : 0;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Encode the RUC segments into a numeric buffer
|
|
73
|
-
* according to entity type, then compute the two
|
|
74
|
-
* DV digits.
|
|
75
|
-
*
|
|
76
|
-
* Returns the two-digit DV string, or null if the
|
|
77
|
-
* format is unrecognized.
|
|
78
|
-
*/
|
|
79
|
-
const computeDV = (segments, raw) => {
|
|
80
|
-
const len = segments.length;
|
|
81
|
-
if (len < 3 || len > 4) return null;
|
|
82
|
-
if (len === 4 !== (segments[1] === "NT")) return null;
|
|
83
|
-
let buf;
|
|
84
|
-
let isOld = false;
|
|
85
|
-
const s0 = segments[0];
|
|
86
|
-
const s1 = segments[1];
|
|
87
|
-
const s2 = segments[2];
|
|
88
|
-
if (raw[0] === "E") buf = z(4 - s1.length) + "00000050050" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
89
|
-
else if (s1 === "NT") {
|
|
90
|
-
const s3 = segments[3];
|
|
91
|
-
const prefix = s0.slice(0, -2);
|
|
92
|
-
buf = z(4 - s1.length) + "0000005" + z(4 - prefix.length) + prefix + "43" + z(3 - s2.length) + s2 + z(5 - s3.length) + s3;
|
|
93
|
-
} else if (s0.endsWith("AV")) {
|
|
94
|
-
const prefix = s0.slice(0, -2);
|
|
95
|
-
buf = z(4 - s1.length) + "0000005" + z(4 - prefix.length) + prefix + "15" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
96
|
-
} else if (s0.endsWith("PI")) {
|
|
97
|
-
const prefix = s0.slice(0, -2);
|
|
98
|
-
buf = z(4 - s1.length) + "0000005" + z(4 - prefix.length) + prefix + "79" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
99
|
-
} else if (s0 === "PE") buf = z(4 - s1.length) + "00000050075" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
100
|
-
else if (raw[0] === "N") buf = z(4 - s1.length) + "00000050040" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
101
|
-
else if (s0.length >= 1 && s0.length <= 2) buf = z(4 - s1.length) + "0000005" + z(2 - s0.length) + s0 + "00" + z(3 - s1.length) + s1 + z(5 - s2.length) + s2;
|
|
102
|
-
else {
|
|
103
|
-
buf = z(10 - s0.length) + s0 + z(4 - s1.length) + s1 + z(6 - s2.length) + s2;
|
|
104
|
-
isOld = buf[3] === "0" && buf[4] === "0" && buf[5] < "5";
|
|
105
|
-
}
|
|
106
|
-
if (isOld) {
|
|
107
|
-
const key = buf.slice(5, 7);
|
|
108
|
-
const mapped = LEGACY_MAP[key] ?? key;
|
|
109
|
-
buf = buf.slice(0, 5) + mapped + buf.slice(7);
|
|
110
|
-
}
|
|
111
|
-
const dv1 = digitDV(buf, isOld);
|
|
112
|
-
return `${dv1}${digitDV(buf + String.fromCharCode(48 + dv1), isOld)}`;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Compact: normalize Unicode, collapse whitespace,
|
|
116
|
-
* strip colons around DV, and uppercase. Keeps
|
|
117
|
-
* hyphens (structural separators) and a single
|
|
118
|
-
* space before "DV".
|
|
119
|
-
*/
|
|
120
|
-
const compact = (value) => {
|
|
121
|
-
let v = clean(value, "").trim().toUpperCase();
|
|
122
|
-
v = v.replace(/\s*DV[:\s]*(\d{2})$/, " DV$1");
|
|
123
|
-
v = v.replace(/\s+/g, " ");
|
|
124
|
-
return v;
|
|
125
|
-
};
|
|
126
|
-
const validate = (value) => {
|
|
127
|
-
const dvMatch = compact(value).match(/^(.+?)-?\s*DV[:\s]*(\d{2})$/);
|
|
128
|
-
if (!dvMatch) return err("INVALID_FORMAT", "Panama RUC must include DV (dígito verificador)");
|
|
129
|
-
const rucPart = dvMatch[1];
|
|
130
|
-
const dvPart = dvMatch[2];
|
|
131
|
-
const segments = rucPart.replace(/-+$/, "").split("-");
|
|
132
|
-
if (segments.length < 3 || segments.length > 4) return err("INVALID_FORMAT", "Panama RUC must have 3–4 hyphen-separated segments");
|
|
133
|
-
if (segments.some((s) => s.length === 0)) return err("INVALID_FORMAT", "Panama RUC segments must not be empty");
|
|
134
|
-
const computed = computeDV(segments, rucPart);
|
|
135
|
-
if (computed === null) return err("INVALID_FORMAT", "Unrecognized Panama RUC format");
|
|
136
|
-
if (computed !== dvPart) return err("INVALID_CHECKSUM", "Panama RUC dígito verificador does not match");
|
|
137
|
-
return {
|
|
138
|
-
valid: true,
|
|
139
|
-
compact: segments.join("-") + " DV" + dvPart
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Format: display as segments with " DV XX".
|
|
144
|
-
*/
|
|
145
|
-
const format = (value) => {
|
|
146
|
-
const v = compact(value);
|
|
147
|
-
const dvMatch = v.match(/^(.+?)-?\s*DV[:\s]*(\d{2})$/);
|
|
148
|
-
if (!dvMatch) return v;
|
|
149
|
-
const rucPart = dvMatch[1].replace(/-+$/, "");
|
|
150
|
-
const dvPart = dvMatch[2];
|
|
151
|
-
return `${rucPart.split("-").join("-")} DV ${dvPart}`;
|
|
152
|
-
};
|
|
153
|
-
/** Generate a random valid Panama RUC (natural person). */
|
|
154
|
-
const generate = () => {
|
|
155
|
-
const segments = [
|
|
156
|
-
String(randomInt(1, 13)),
|
|
157
|
-
String(randomInt(1, 9999)),
|
|
158
|
-
String(randomInt(1, 99999))
|
|
159
|
-
];
|
|
160
|
-
const dv = computeDV(segments, segments.join("-"));
|
|
161
|
-
if (dv === null) throw new Error("Failed to compute Panama RUC DV");
|
|
162
|
-
return `${segments.join("-")} DV${dv}`;
|
|
163
|
-
};
|
|
164
|
-
/** Panama tax identification number. */
|
|
165
|
-
const ruc = {
|
|
166
|
-
name: "Tax Identification Number",
|
|
167
|
-
localName: "Registro Único de Contribuyente",
|
|
168
|
-
abbreviation: "RUC",
|
|
169
|
-
aliases: ["RUC"],
|
|
170
|
-
candidatePattern: "\\d{1,2}-?\\d{1,4}-?\\d{1,6}",
|
|
171
|
-
scope: "country",
|
|
172
|
-
country: "PA",
|
|
173
|
-
entityType: "any",
|
|
174
|
-
description: "Tax identifier issued by Panama's DGI",
|
|
175
|
-
sourceUrl: "https://dgi.mef.gob.pa/",
|
|
176
|
-
examples: ["1-184-921 DV49", "2588017-1-831938 DV20"],
|
|
177
|
-
compact,
|
|
178
|
-
format,
|
|
179
|
-
validate,
|
|
180
|
-
generate
|
|
181
|
-
};
|
|
1
|
+
import { createValidator } from "../runtime.js";
|
|
2
|
+
//#region src/generated/pa/ruc.ts
|
|
3
|
+
const ruc = createValidator("pa.ruc", 140);
|
|
4
|
+
const compact = ruc.compact;
|
|
5
|
+
const format = ruc.format;
|
|
6
|
+
const validate = ruc.validate;
|
|
7
|
+
const generate = () => ruc.generate?.() ?? (() => {
|
|
8
|
+
throw new Error("Validator pa.ruc cannot generate values");
|
|
9
|
+
})();
|
|
182
10
|
//#endregion
|
|
183
11
|
export { compact, ruc as default, format, generate, validate };
|
|
184
12
|
|
package/dist/pa/ruc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruc.js","names":[],"sources":["../../src/pa/ruc.ts"],"sourcesContent":["/**\n * RUC (Registro Único de Contribuyente, Panama\n * tax number).\n *\n * The RUC identifies taxpayers in Panama. It comes\n * in several formats depending on entity type\n * (natural person, legal entity, foreigner, etc.)\n * and is always accompanied by a two-digit check\n * code called the \"dígito verificador\" (DV).\n *\n * The DV is computed by encoding the hyphen-separated\n * RUC into a 20-position numeric buffer, then applying\n * a double weighted-sum mod 11 algorithm. The encoding\n * and legacy-format handling follow the official ANIP/DGI\n * specification.\n *\n * @see https://dgi.mef.gob.pa/\n */\n\nimport type {\n ValidateResult,\n CountryValidator,\n} from \"../types\";\n\nimport { clean } from \"#util/clean\";\nimport { randomInt } from \"#util/generate\";\nimport { err } from \"#util/result\";\n\n/**\n * Legacy cross-reference table: maps two-digit codes\n * at positions 5–6 of old-format juridical RUCs.\n */\nconst LEGACY_MAP: Record<string, string> = {\n \"00\": \"00\",\n \"10\": \"01\",\n \"11\": \"02\",\n \"12\": \"03\",\n \"13\": \"04\",\n \"14\": \"05\",\n \"15\": \"06\",\n \"16\": \"07\",\n \"17\": \"08\",\n \"18\": \"09\",\n \"19\": \"01\",\n \"20\": \"02\",\n \"21\": \"03\",\n \"22\": \"04\",\n \"23\": \"07\",\n \"24\": \"08\",\n \"25\": \"09\",\n \"26\": \"02\",\n \"27\": \"03\",\n \"28\": \"04\",\n \"29\": \"05\",\n \"30\": \"06\",\n \"31\": \"07\",\n \"32\": \"08\",\n \"33\": \"09\",\n \"34\": \"01\",\n \"35\": \"02\",\n \"36\": \"03\",\n \"37\": \"04\",\n \"38\": \"05\",\n \"39\": \"06\",\n \"40\": \"07\",\n \"41\": \"08\",\n \"42\": \"09\",\n \"43\": \"01\",\n \"44\": \"02\",\n \"45\": \"03\",\n \"46\": \"04\",\n \"47\": \"05\",\n \"48\": \"06\",\n \"49\": \"07\",\n};\n\n/** Prepend n leading zeros. */\nconst z = (n: number): string => \"0\".repeat(Math.max(0, n));\n\n/**\n * Compute a single DV digit via weighted sum mod 11.\n * Weights start at 2 and increment, applied\n * right-to-left. For old-format juridical RUCs,\n * weight 12 is skipped (jumps from 11 to 13).\n */\nconst digitDV = (\n buf: string,\n isOldFormat: boolean,\n): number => {\n let weight = 2;\n let sum = 0;\n for (let i = buf.length - 1; i >= 0; i--) {\n if (isOldFormat && weight === 12) {\n weight += 1; // skip 12, continue from 13\n }\n sum += weight * (buf.charCodeAt(i) - 48);\n weight += 1;\n }\n const r = sum % 11;\n return r > 1 ? 11 - r : 0;\n};\n\n/**\n * Encode the RUC segments into a numeric buffer\n * according to entity type, then compute the two\n * DV digits.\n *\n * Returns the two-digit DV string, or null if the\n * format is unrecognized.\n */\nconst computeDV = (\n segments: readonly string[],\n raw: string,\n): string | null => {\n const len = segments.length;\n\n if (len < 3 || len > 4) {\n return null;\n }\n // The NT designation requires exactly 4 segments\n // (xxNT-NT-xxx-xxx); any other 4-segment shape is\n // unrecognized, and a 3-segment \"NT\" in position 1\n // is malformed.\n if ((len === 4) !== (segments[1] === \"NT\")) {\n return null;\n }\n\n let buf: string;\n let isOld = false;\n\n // SAFETY: length check above ensures 3..4 segments.\n // eslint-disable-next-line no-non-null-assertion\n const s0 = segments[0]!;\n // eslint-disable-next-line no-non-null-assertion\n const s1 = segments[1]!;\n // eslint-disable-next-line no-non-null-assertion\n const s2 = segments[2]!;\n\n if (raw[0] === \"E\") {\n // Foreign person (E-xxx-xxx)\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n \"00\" +\n \"50\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else if (s1 === \"NT\") {\n // NT designation (xxNT-NT-xxx-xxx)\n // SAFETY: NT branch implies len === 4 (checked above).\n // eslint-disable-next-line no-non-null-assertion\n const s3 = segments[3]!;\n const prefix = s0.slice(0, -2);\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n z(4 - prefix.length) +\n prefix +\n \"43\" +\n z(3 - s2.length) +\n s2 +\n z(5 - s3.length) +\n s3;\n } else if (s0.endsWith(\"AV\")) {\n // AV suffix\n const prefix = s0.slice(0, -2);\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n z(4 - prefix.length) +\n prefix +\n \"15\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else if (s0.endsWith(\"PI\")) {\n // PI suffix\n const prefix = s0.slice(0, -2);\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n z(4 - prefix.length) +\n prefix +\n \"79\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else if (s0 === \"PE\") {\n // PE prefix (foreign-born)\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n \"00\" +\n \"75\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else if (raw[0] === \"N\") {\n // N prefix (naturalized citizen)\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n \"00\" +\n \"40\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else if (s0.length >= 1 && s0.length <= 2) {\n // Natural person (province 1–2 digits)\n buf =\n z(4 - s1.length) +\n \"0000005\" +\n z(2 - s0.length) +\n s0 +\n \"00\" +\n z(3 - s1.length) +\n s1 +\n z(5 - s2.length) +\n s2;\n } else {\n // Juridical (company)\n buf =\n z(10 - s0.length) +\n s0 +\n z(4 - s1.length) +\n s1 +\n z(6 - s2.length) +\n s2;\n // SAFETY: juridical branch zero-pads s0 to at least\n // 10 chars (z(10 - s0.length)), so buf[3..6] are\n // always defined.\n isOld =\n buf[3] === \"0\" &&\n buf[4] === \"0\" &&\n // eslint-disable-next-line no-non-null-assertion\n buf[5]! < \"5\";\n }\n\n // Apply legacy cross-reference for old format\n if (isOld) {\n const key = buf.slice(5, 7);\n const mapped = LEGACY_MAP[key] ?? key;\n buf = buf.slice(0, 5) + mapped + buf.slice(7);\n }\n\n const dv1 = digitDV(buf, isOld);\n const dv2 = digitDV(\n buf + String.fromCharCode(48 + dv1),\n isOld,\n );\n\n return `${dv1}${dv2}`;\n};\n\n/**\n * Compact: normalize Unicode, collapse whitespace,\n * strip colons around DV, and uppercase. Keeps\n * hyphens (structural separators) and a single\n * space before \"DV\".\n */\nconst compact = (value: string): string => {\n let v = clean(value, \"\").trim().toUpperCase();\n // Normalize DV portion: \" DV: 49\" -> \" DV49\"\n v = v.replace(/\\s*DV[:\\s]*(\\d{2})$/, \" DV$1\");\n // Collapse any remaining internal whitespace\n v = v.replace(/\\s+/g, \" \");\n return v;\n};\n\nconst validate = (value: string): ValidateResult => {\n const v = compact(value);\n\n // Extract the DV portion: \"...DV49\", \"...DV:49\",\n // or \"... DV 49\"\n const dvMatch = v.match(/^(.+?)-?\\s*DV[:\\s]*(\\d{2})$/);\n\n if (!dvMatch) {\n return err(\n \"INVALID_FORMAT\",\n \"Panama RUC must include DV \" +\n \"(dígito verificador)\",\n );\n }\n\n // SAFETY: both DV regex capture groups are required.\n // eslint-disable-next-line no-non-null-assertion\n const rucPart = dvMatch[1]!;\n // eslint-disable-next-line no-non-null-assertion\n const dvPart = dvMatch[2]!;\n\n // The RUC part should be hyphen-separated segments\n const segments = rucPart.replace(/-+$/, \"\").split(\"-\");\n\n if (segments.length < 3 || segments.length > 4) {\n return err(\n \"INVALID_FORMAT\",\n \"Panama RUC must have 3–4 \" +\n \"hyphen-separated segments\",\n );\n }\n\n if (segments.some((s) => s.length === 0)) {\n return err(\n \"INVALID_FORMAT\",\n \"Panama RUC segments must not be empty\",\n );\n }\n\n const computed = computeDV(segments, rucPart);\n if (computed === null) {\n return err(\n \"INVALID_FORMAT\",\n \"Unrecognized Panama RUC format\",\n );\n }\n\n if (computed !== dvPart) {\n return err(\n \"INVALID_CHECKSUM\",\n \"Panama RUC dígito verificador \" + \"does not match\",\n );\n }\n\n const compactForm = segments.join(\"-\") + \" DV\" + dvPart;\n return { valid: true, compact: compactForm };\n};\n\n/**\n * Format: display as segments with \" DV XX\".\n */\nconst format = (value: string): string => {\n const v = compact(value);\n const dvMatch = v.match(/^(.+?)-?\\s*DV[:\\s]*(\\d{2})$/);\n if (!dvMatch) return v;\n\n // SAFETY: both DV regex capture groups are required.\n // eslint-disable-next-line no-non-null-assertion\n const rucPart = dvMatch[1]!.replace(/-+$/, \"\");\n // eslint-disable-next-line no-non-null-assertion\n const dvPart = dvMatch[2]!;\n const segments = rucPart.split(\"-\");\n return `${segments.join(\"-\")} DV ${dvPart}`;\n};\n\n/** Generate a random valid Panama RUC (natural person). */\nconst generate = (): string => {\n const province = String(randomInt(1, 13));\n const volume = String(randomInt(1, 9999));\n const folio = String(randomInt(1, 99999));\n const segments = [province, volume, folio];\n const dv = computeDV(segments, segments.join(\"-\"));\n if (dv === null) {\n throw new Error(\"Failed to compute Panama RUC DV\");\n }\n return `${segments.join(\"-\")} DV${dv}`;\n};\n\n/** Panama tax identification number. */\nconst ruc: CountryValidator<\"PA\"> = {\n name: \"Tax Identification Number\",\n localName: \"Registro Único de Contribuyente\",\n abbreviation: \"RUC\",\n aliases: [\"RUC\"] as const,\n candidatePattern: \"\\\\d{1,2}-?\\\\d{1,4}-?\\\\d{1,6}\",\n scope: \"country\",\n country: \"PA\",\n entityType: \"any\",\n description: \"Tax identifier issued by Panama's DGI\",\n sourceUrl: \"https://dgi.mef.gob.pa/\",\n examples: [\n \"1-184-921 DV49\",\n \"2588017-1-831938 DV20\",\n ] as const,\n compact,\n format,\n validate,\n generate,\n};\n\nexport default ruc;\nexport { compact, format, validate, generate };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"ruc.js","names":[],"sources":["../../src/generated/pa/ruc.ts"],"sourcesContent":["// Generated by scripts/generate-public-surface.ts. Do not edit.\nimport { createValidator } from \"../../runtime\";\nimport type { CountryValidator } from \"../../types\";\n\nconst ruc: CountryValidator<\"PA\"> = createValidator(\n \"pa.ruc\",\n 140,\n);\n\nexport default ruc;\nexport const compact = ruc.compact;\nexport const format = ruc.format;\nexport const validate = ruc.validate;\nexport const generate = (): string =>\n ruc.generate?.() ??\n (() => {\n throw new Error(\n \"Validator pa.ruc cannot generate values\",\n );\n })();\n"],"mappings":";;AAIA,MAAM,MAA8B,gBAClC,UACA,GACF;AAGA,MAAa,UAAU,IAAI;AAC3B,MAAa,SAAS,IAAI;AAC1B,MAAa,WAAW,IAAI;AAC5B,MAAa,iBACX,IAAI,WAAW,YACR;CACL,MAAM,IAAI,MACR,yCACF;AACF,EAAA,CAAG"}
|
package/dist/patterns.d.ts
CHANGED
|
@@ -1,43 +1,14 @@
|
|
|
1
|
-
import { CountryCode, CountryValidator, Validator } from "./types.js";
|
|
2
|
-
|
|
1
|
+
import { CountryCode, CountryValidator, GlobalValidator, ParsedBirthDate, ParsedPersonId, Validator } from "./types.js";
|
|
3
2
|
//#region src/patterns.d.ts
|
|
4
3
|
type ValidatorPattern<TValidator extends Validator = Validator> = {
|
|
5
|
-
|
|
4
|
+
validator: TValidator;
|
|
6
5
|
regex: RegExp;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
* Derive a loose candidate-matching regex from
|
|
10
|
-
* a validator. The regex finds potential matches;
|
|
11
|
-
* use `validate()` to confirm.
|
|
12
|
-
*
|
|
13
|
-
* Handles both digit-only (IČO, NIP) and
|
|
14
|
-
* alphanumeric (IBAN, BIC, ISIN, LEI) validators.
|
|
15
|
-
*/
|
|
16
|
-
declare const toRegex: (v: Validator) => RegExp;
|
|
17
|
-
/**
|
|
18
|
-
* All discovered validators, lazily populated.
|
|
19
|
-
* Import * from "../src" would pull everything;
|
|
20
|
-
* instead, callers pass validators explicitly.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Build patterns for a list of validators.
|
|
24
|
-
*/
|
|
7
|
+
declare const toRegex: (validator: Validator) => RegExp;
|
|
25
8
|
declare const toPatterns: <TValidator extends Validator>(validators: readonly TValidator[]) => ValidatorPattern<TValidator>[];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
type CountryScopedValidator<TValidator extends Validator, TCountry extends CountryCode> = TValidator extends CountryValidator<infer TValidatorCountry, infer TParsed> ? TCountry extends TValidatorCountry ? TValidator & CountryValidator<TCountry, TParsed> : TValidatorCountry extends TCountry ? TValidator : never : never;
|
|
31
|
-
declare const byCountry: <TCountry extends CountryCode, TValidator extends Validator>(country: TCountry, validators: readonly TValidator[]) => ValidatorPattern<CountryScopedValidator<TValidator, TCountry>>[];
|
|
32
|
-
/**
|
|
33
|
-
* Filter validators by entity type and build
|
|
34
|
-
* patterns.
|
|
35
|
-
*/
|
|
36
|
-
declare const byEntityType: <TValidator extends Validator>(entityType: "person" | "company" | "any", validators: readonly TValidator[]) => ValidatorPattern<TValidator>[];
|
|
37
|
-
/**
|
|
38
|
-
* Build patterns for ALL provided validators.
|
|
39
|
-
*/
|
|
40
|
-
declare const allPatterns: <TValidator extends Validator>(validators: readonly TValidator[]) => ValidatorPattern<TValidator>[];
|
|
9
|
+
declare const byCountry: <TCountry extends CountryCode>(country: TCountry) => ValidatorPattern<CountryValidator<TCountry>>[];
|
|
10
|
+
declare const byEntityType: (entityType: Validator["entityType"]) => ValidatorPattern<CountryValidator<"AD"> | CountryValidator<"AE"> | CountryValidator<"AI"> | CountryValidator<"AL"> | CountryValidator<"AM"> | CountryValidator<"AR"> | CountryValidator<"AT"> | CountryValidator<"AU"> | CountryValidator<"AZ"> | CountryValidator<"BD"> | CountryValidator<"BE"> | CountryValidator<"BG"> | CountryValidator<"BH"> | CountryValidator<"BR"> | CountryValidator<"BY"> | CountryValidator<"BZ"> | CountryValidator<"CA"> | CountryValidator<"CH"> | CountryValidator<"CL"> | CountryValidator<"CN"> | CountryValidator<"CO"> | CountryValidator<"CR"> | CountryValidator<"CY"> | CountryValidator<"CZ"> | CountryValidator<"DE"> | CountryValidator<"DK"> | CountryValidator<"DO"> | CountryValidator<"EC"> | CountryValidator<"EE"> | CountryValidator<"EG"> | CountryValidator<"ES"> | CountryValidator<"FI"> | CountryValidator<"FR"> | CountryValidator<"GB"> | CountryValidator<"GE"> | CountryValidator<"GH"> | CountryValidator<"GR"> | CountryValidator<"GT"> | CountryValidator<"HK"> | CountryValidator<"HR"> | CountryValidator<"HU"> | CountryValidator<"ID"> | CountryValidator<"IE"> | CountryValidator<"IL"> | CountryValidator<"IN"> | CountryValidator<"IQ"> | CountryValidator<"IR"> | CountryValidator<"IS"> | CountryValidator<"IT"> | CountryValidator<"JP"> | CountryValidator<"KR"> | CountryValidator<"LI"> | CountryValidator<"LT"> | CountryValidator<"LU"> | CountryValidator<"LV"> | CountryValidator<"MA"> | CountryValidator<"MC"> | CountryValidator<"MD"> | CountryValidator<"ME"> | CountryValidator<"MK"> | CountryValidator<"MT"> | CountryValidator<"MU"> | CountryValidator<"MX"> | CountryValidator<"NG"> | CountryValidator<"NI"> | CountryValidator<"NL"> | CountryValidator<"NO"> | CountryValidator<"NZ"> | CountryValidator<"PA"> | CountryValidator<"PE"> | CountryValidator<"PH"> | CountryValidator<"PK"> | CountryValidator<"PL"> | CountryValidator<"PT"> | CountryValidator<"RO"> | CountryValidator<"RS"> | CountryValidator<"RU"> | CountryValidator<"SE"> | CountryValidator<"SG"> | CountryValidator<"SI"> | CountryValidator<"SK"> | CountryValidator<"TH"> | CountryValidator<"TR"> | CountryValidator<"TW"> | CountryValidator<"UA"> | CountryValidator<"US"> | CountryValidator<"UY"> | CountryValidator<"VE"> | CountryValidator<"VN"> | CountryValidator<"BA", ParsedPersonId> | CountryValidator<"BG", ParsedPersonId> | CountryValidator<"CN", ParsedPersonId> | CountryValidator<"CU", ParsedPersonId> | CountryValidator<"CZ", ParsedPersonId> | CountryValidator<"DK", ParsedPersonId> | CountryValidator<"EE", ParsedPersonId> | CountryValidator<"FI", ParsedPersonId> | CountryValidator<"FR", ParsedPersonId> | CountryValidator<"IT", ParsedPersonId> | CountryValidator<"KR", ParsedPersonId> | CountryValidator<"KW", ParsedBirthDate> | CountryValidator<"KZ", ParsedPersonId> | CountryValidator<"LK", ParsedPersonId> | CountryValidator<"MX", ParsedPersonId> | CountryValidator<"MY", ParsedPersonId> | CountryValidator<"NO", ParsedPersonId> | CountryValidator<"PL", ParsedPersonId> | CountryValidator<"RO", ParsedPersonId> | CountryValidator<"SE", ParsedPersonId> | CountryValidator<"SI", ParsedPersonId> | CountryValidator<"SK", ParsedPersonId> | CountryValidator<"ZA", ParsedPersonId> | GlobalValidator>[];
|
|
11
|
+
declare const allPatterns: () => ValidatorPattern<CountryValidator<"AD"> | CountryValidator<"AE"> | CountryValidator<"AI"> | CountryValidator<"AL"> | CountryValidator<"AM"> | CountryValidator<"AR"> | CountryValidator<"AT"> | CountryValidator<"AU"> | CountryValidator<"AZ"> | CountryValidator<"BD"> | CountryValidator<"BE"> | CountryValidator<"BG"> | CountryValidator<"BH"> | CountryValidator<"BR"> | CountryValidator<"BY"> | CountryValidator<"BZ"> | CountryValidator<"CA"> | CountryValidator<"CH"> | CountryValidator<"CL"> | CountryValidator<"CN"> | CountryValidator<"CO"> | CountryValidator<"CR"> | CountryValidator<"CY"> | CountryValidator<"CZ"> | CountryValidator<"DE"> | CountryValidator<"DK"> | CountryValidator<"DO"> | CountryValidator<"EC"> | CountryValidator<"EE"> | CountryValidator<"EG"> | CountryValidator<"ES"> | CountryValidator<"FI"> | CountryValidator<"FR"> | CountryValidator<"GB"> | CountryValidator<"GE"> | CountryValidator<"GH"> | CountryValidator<"GR"> | CountryValidator<"GT"> | CountryValidator<"HK"> | CountryValidator<"HR"> | CountryValidator<"HU"> | CountryValidator<"ID"> | CountryValidator<"IE"> | CountryValidator<"IL"> | CountryValidator<"IN"> | CountryValidator<"IQ"> | CountryValidator<"IR"> | CountryValidator<"IS"> | CountryValidator<"IT"> | CountryValidator<"JP"> | CountryValidator<"KR"> | CountryValidator<"LI"> | CountryValidator<"LT"> | CountryValidator<"LU"> | CountryValidator<"LV"> | CountryValidator<"MA"> | CountryValidator<"MC"> | CountryValidator<"MD"> | CountryValidator<"ME"> | CountryValidator<"MK"> | CountryValidator<"MT"> | CountryValidator<"MU"> | CountryValidator<"MX"> | CountryValidator<"NG"> | CountryValidator<"NI"> | CountryValidator<"NL"> | CountryValidator<"NO"> | CountryValidator<"NZ"> | CountryValidator<"PA"> | CountryValidator<"PE"> | CountryValidator<"PH"> | CountryValidator<"PK"> | CountryValidator<"PL"> | CountryValidator<"PT"> | CountryValidator<"RO"> | CountryValidator<"RS"> | CountryValidator<"RU"> | CountryValidator<"SE"> | CountryValidator<"SG"> | CountryValidator<"SI"> | CountryValidator<"SK"> | CountryValidator<"TH"> | CountryValidator<"TR"> | CountryValidator<"TW"> | CountryValidator<"UA"> | CountryValidator<"US"> | CountryValidator<"UY"> | CountryValidator<"VE"> | CountryValidator<"VN"> | CountryValidator<"BA", ParsedPersonId> | CountryValidator<"BG", ParsedPersonId> | CountryValidator<"CN", ParsedPersonId> | CountryValidator<"CU", ParsedPersonId> | CountryValidator<"CZ", ParsedPersonId> | CountryValidator<"DK", ParsedPersonId> | CountryValidator<"EE", ParsedPersonId> | CountryValidator<"FI", ParsedPersonId> | CountryValidator<"FR", ParsedPersonId> | CountryValidator<"IT", ParsedPersonId> | CountryValidator<"KR", ParsedPersonId> | CountryValidator<"KW", ParsedBirthDate> | CountryValidator<"KZ", ParsedPersonId> | CountryValidator<"LK", ParsedPersonId> | CountryValidator<"MX", ParsedPersonId> | CountryValidator<"MY", ParsedPersonId> | CountryValidator<"NO", ParsedPersonId> | CountryValidator<"PL", ParsedPersonId> | CountryValidator<"RO", ParsedPersonId> | CountryValidator<"SE", ParsedPersonId> | CountryValidator<"SI", ParsedPersonId> | CountryValidator<"SK", ParsedPersonId> | CountryValidator<"ZA", ParsedPersonId> | GlobalValidator>[];
|
|
41
12
|
//#endregion
|
|
42
13
|
export { ValidatorPattern, allPatterns, byCountry, byEntityType, toPatterns, toRegex };
|
|
43
14
|
//# sourceMappingURL=patterns.d.ts.map
|
package/dist/patterns.js
CHANGED
|
@@ -1,177 +1,16 @@
|
|
|
1
|
+
import { allValidators } from "./registry.js";
|
|
1
2
|
//#region src/patterns.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Infer compact lengths from metadata or examples.
|
|
6
|
-
*/
|
|
7
|
-
const inferLengths = (v) => {
|
|
8
|
-
if (v.lengths && v.lengths.length > 0) return [...v.lengths];
|
|
9
|
-
if (v.examples && v.examples.length > 0) {
|
|
10
|
-
const lens = /* @__PURE__ */ new Set();
|
|
11
|
-
for (const ex of v.examples) lens.add(v.compact(ex).length);
|
|
12
|
-
return [...lens];
|
|
13
|
-
}
|
|
14
|
-
return [];
|
|
3
|
+
const toRegex = (validator) => {
|
|
4
|
+
if (validator.candidatePattern === void 0) throw new Error(`${validator.name} does not define a candidate pattern`);
|
|
5
|
+
return new RegExp(validator.candidatePattern, "g");
|
|
15
6
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* "25 123 891" → [2, 3, 3].
|
|
20
|
-
*/
|
|
21
|
-
const inferGroups = (v) => {
|
|
22
|
-
const first = v.examples?.[0];
|
|
23
|
-
if (first === void 0) return null;
|
|
24
|
-
const compact = v.compact(first);
|
|
25
|
-
const formatted = v.format(compact);
|
|
26
|
-
if (formatted === compact) return null;
|
|
27
|
-
const parts = formatted.split(/[^a-zA-Z0-9]+/);
|
|
28
|
-
if (parts.length <= 1) return null;
|
|
29
|
-
const isAlphanumeric = parts.some((p) => /[a-zA-Z]/.test(p) && /\d/.test(p));
|
|
30
|
-
const groups = parts.filter((p) => p.length > 0 && (isAlphanumeric || /\d/.test(p))).map((p) => p.length);
|
|
31
|
-
return groups.length > 1 ? groups : null;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Detect if this validator uses a known prefix
|
|
35
|
-
* (e.g., "CZ" for DIČ, "CHE" for Swiss UID).
|
|
36
|
-
*/
|
|
37
|
-
const inferPrefix = (v) => {
|
|
38
|
-
const examples = v.examples;
|
|
39
|
-
const first = examples?.[0];
|
|
40
|
-
if (!examples || first === void 0) return null;
|
|
41
|
-
const compact = v.compact(first);
|
|
42
|
-
const compactPrefix = compact.match(/^([A-Z]+)\d/)?.[1];
|
|
43
|
-
if (compactPrefix !== void 0 && examples.length > 1) {
|
|
44
|
-
if (examples.every((ex) => v.compact(ex).startsWith(compactPrefix))) return compactPrefix;
|
|
45
|
-
} else if (compactPrefix !== void 0 && examples.length === 1) return compactPrefix;
|
|
46
|
-
const fmtPrefix = v.format(compact).match(/^([A-Z]+)[\s\-./]?\d/)?.[1];
|
|
47
|
-
if (fmtPrefix !== void 0 && !compact.startsWith(fmtPrefix)) return fmtPrefix;
|
|
48
|
-
return null;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Character class for a string fragment:
|
|
52
|
-
* `\d` if all digits, `[A-Z]` if all letters,
|
|
53
|
-
* `[A-Z0-9]` if mixed.
|
|
54
|
-
*/
|
|
55
|
-
const charClassFor = (s) => {
|
|
56
|
-
let hasLetter = false;
|
|
57
|
-
let hasDigit = false;
|
|
58
|
-
for (const ch of s) {
|
|
59
|
-
if (/[a-zA-Z]/.test(ch)) hasLetter = true;
|
|
60
|
-
if (/\d/.test(ch)) hasDigit = true;
|
|
61
|
-
}
|
|
62
|
-
if (hasLetter && hasDigit) return "[A-Z0-9]";
|
|
63
|
-
if (hasLetter) return "[A-Z]";
|
|
64
|
-
return "\\d";
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Determine the character class needed for the
|
|
68
|
-
* compact form: `\d` if all digits, `[A-Z0-9]`
|
|
69
|
-
* if alphanumeric, etc.
|
|
70
|
-
*/
|
|
71
|
-
const inferCharClass = (v) => {
|
|
72
|
-
if (!v.examples || v.examples.length === 0) return "\\d";
|
|
73
|
-
return charClassFor(v.examples.map((ex) => v.compact(ex)).join(""));
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Infer per-group sizes AND character classes from
|
|
77
|
-
* format(). Returns groups with per-position char
|
|
78
|
-
* classes, e.g., "12 010188 M 01 1" →
|
|
79
|
-
* sizes: [2, 6, 1, 2, 1]
|
|
80
|
-
* classes: ["\d", "\d", "[A-Z]", "\d", "\d"]
|
|
81
|
-
*
|
|
82
|
-
* Only returns non-null when per-group classes
|
|
83
|
-
* differ (some groups are letters, some digits).
|
|
84
|
-
* Letter-only groups before the first digit group
|
|
85
|
-
* are treated as prefixes and excluded (handled
|
|
86
|
-
* by inferPrefix separately).
|
|
87
|
-
*/
|
|
88
|
-
const inferPerGroup = (v) => {
|
|
89
|
-
const first = v.examples?.[0];
|
|
90
|
-
if (first === void 0) return null;
|
|
91
|
-
const compact = v.compact(first);
|
|
92
|
-
const formatted = v.format(compact);
|
|
93
|
-
if (formatted === compact) return null;
|
|
94
|
-
if (!(/[a-zA-Z]/.test(compact) && /\d/.test(compact))) return null;
|
|
95
|
-
const parts = formatted.split(/[^a-zA-Z0-9]+/);
|
|
96
|
-
if (parts.some((p) => /[a-zA-Z]/.test(p) && /\d/.test(p))) return null;
|
|
97
|
-
const filtered = [];
|
|
98
|
-
let seenDigitGroup = false;
|
|
99
|
-
for (const p of parts) {
|
|
100
|
-
if (p.length === 0) continue;
|
|
101
|
-
if (/\d/.test(p)) {
|
|
102
|
-
seenDigitGroup = true;
|
|
103
|
-
filtered.push({
|
|
104
|
-
size: p.length,
|
|
105
|
-
charClass: charClassFor(p)
|
|
106
|
-
});
|
|
107
|
-
} else if (seenDigitGroup) filtered.push({
|
|
108
|
-
size: p.length,
|
|
109
|
-
charClass: charClassFor(p)
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (filtered.length <= 1) return null;
|
|
113
|
-
const firstClass = filtered[0]?.charClass;
|
|
114
|
-
if (filtered.every((g) => g.charClass === firstClass)) return null;
|
|
115
|
-
return filtered;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Build a group regex from group sizes + char class.
|
|
119
|
-
* [2, 3, 3] with \d → /\d{2}[\s\-.]?\d{3}[\s\-.]?\d{3}/
|
|
120
|
-
*/
|
|
121
|
-
const groupsToPattern = (groups, cc) => groups.map((g) => `${cc}{${g}}`).join(SEP);
|
|
122
|
-
/**
|
|
123
|
-
* Build a group regex with per-group char classes.
|
|
124
|
-
* Produces tighter patterns when groups have different
|
|
125
|
-
* character types (e.g., digits vs letters).
|
|
126
|
-
*/
|
|
127
|
-
const groupsToPatternPerClass = (groups) => groups.map(({ size, charClass }) => `${charClass}{${size}}`).join(SEP);
|
|
128
|
-
/**
|
|
129
|
-
* Derive a loose candidate-matching regex from
|
|
130
|
-
* a validator. The regex finds potential matches;
|
|
131
|
-
* use `validate()` to confirm.
|
|
132
|
-
*
|
|
133
|
-
* Handles both digit-only (IČO, NIP) and
|
|
134
|
-
* alphanumeric (IBAN, BIC, ISIN, LEI) validators.
|
|
135
|
-
*/
|
|
136
|
-
const toRegex = (v) => {
|
|
137
|
-
const prefix = inferPrefix(v);
|
|
138
|
-
const groups = inferGroups(v);
|
|
139
|
-
const lengths = inferLengths(v);
|
|
140
|
-
const cc = inferCharClass(v);
|
|
141
|
-
let pattern;
|
|
142
|
-
const perGroup = inferPerGroup(v);
|
|
143
|
-
if (perGroup && lengths.length <= 1) pattern = groupsToPatternPerClass(perGroup);
|
|
144
|
-
else if (groups && lengths.length <= 1) pattern = groupsToPattern(groups, cc);
|
|
145
|
-
else if (lengths.length === 1) pattern = `${cc}{${lengths[0]}}`;
|
|
146
|
-
else if (lengths.length > 1) pattern = `${cc}{${Math.min(...lengths)},${Math.max(...lengths)}}`;
|
|
147
|
-
else pattern = `${cc}{6,20}`;
|
|
148
|
-
if (prefix) pattern = `${prefix}${SEP}${pattern}`;
|
|
149
|
-
return new RegExp(`(?<!\\w)${pattern}(?!\\w)`, "g");
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* All discovered validators, lazily populated.
|
|
153
|
-
* Import * from "../src" would pull everything;
|
|
154
|
-
* instead, callers pass validators explicitly.
|
|
155
|
-
*/
|
|
156
|
-
/**
|
|
157
|
-
* Build patterns for a list of validators.
|
|
158
|
-
*/
|
|
159
|
-
const toPatterns = (validators) => validators.map((v) => ({
|
|
160
|
-
validator: v,
|
|
161
|
-
regex: toRegex(v)
|
|
7
|
+
const toPatterns = (validators) => validators.filter((validator) => validator.candidatePattern !== void 0).map((validator) => ({
|
|
8
|
+
validator,
|
|
9
|
+
regex: toRegex(validator)
|
|
162
10
|
}));
|
|
163
|
-
const byCountry = (country
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Filter validators by entity type and build
|
|
168
|
-
* patterns.
|
|
169
|
-
*/
|
|
170
|
-
const byEntityType = (entityType, validators) => toPatterns(validators.filter((v) => entityType === "any" || v.entityType === entityType || v.entityType === "any"));
|
|
171
|
-
/**
|
|
172
|
-
* Build patterns for ALL provided validators.
|
|
173
|
-
*/
|
|
174
|
-
const allPatterns = (validators) => toPatterns(validators);
|
|
11
|
+
const byCountry = (country) => toPatterns(allValidators.filter((validator) => validator.scope === "country" && validator.country === country));
|
|
12
|
+
const byEntityType = (entityType) => toPatterns(allValidators.filter((validator) => validator.entityType === entityType));
|
|
13
|
+
const allPatterns = () => toPatterns(allValidators);
|
|
175
14
|
//#endregion
|
|
176
15
|
export { allPatterns, byCountry, byEntityType, toPatterns, toRegex };
|
|
177
16
|
|
package/dist/patterns.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.js","names":[],"sources":["../src/patterns.ts"],"sourcesContent":["/**\n * Derive candidate-matching regex patterns from\n * validators. These patterns find CANDIDATES in\n * text — use `validate()` to confirm each match.\n *\n * Designed for integration with regex-set or\n * similar multi-pattern scanning engines.\n *\n * @example\n * ```ts\n * import {\n * toRegex, byCountry, byEntityType,\n * } from \"@stll/stdnum/patterns\";\n * import { cz } from \"@stll/stdnum\";\n *\n * // Single validator\n * toRegex(cz.ico);\n * // → /(?<!\\w)\\d{8}(?!\\w)/g\n *\n * // All Czech validators\n * byCountry(\"CZ\");\n * // → [{ validator: cz.ico, regex }, ...]\n *\n * // All company identifiers\n * byEntityType(\"company\");\n * // → [{ validator, regex }, ...]\n * ```\n */\n\nimport type {\n CountryCode,\n CountryValidator,\n Validator,\n} from \"./types\";\n\n// ─── Pattern type ─────────────────────────────\n\nexport type ValidatorPattern<\n TValidator extends Validator = Validator,\n> = {\n /** The validator this pattern was derived from. */\n validator: TValidator;\n /** Loose regex matching candidates in text. */\n regex: RegExp;\n};\n\n// ─── Regex derivation ─────────────────────────\n\n/** Separator chars that compact() strips. */\nconst SEP = \"[\\\\s\\\\-./]?\";\n\n/**\n * Infer compact lengths from metadata or examples.\n */\nconst inferLengths = (v: Validator): number[] => {\n if (v.lengths && v.lengths.length > 0) {\n return [...v.lengths];\n }\n if (v.examples && v.examples.length > 0) {\n const lens = new Set<number>();\n for (const ex of v.examples) {\n lens.add(v.compact(ex).length);\n }\n return [...lens];\n }\n return [];\n};\n\n/**\n * Derive the display grouping from format().\n * Returns an array of group sizes, e.g.,\n * \"25 123 891\" → [2, 3, 3].\n */\nconst inferGroups = (v: Validator): number[] | null => {\n const first = v.examples?.[0];\n if (first === undefined) return null;\n const compact = v.compact(first);\n const formatted = v.format(compact);\n if (formatted === compact) return null;\n\n // Split on non-alphanumeric separators\n const parts = formatted.split(/[^a-zA-Z0-9]+/);\n if (parts.length <= 1) return null;\n\n // For digit-only validators, skip letter-only\n // tokens (prefix like \"CHE\"). For alphanumeric\n // validators (IBAN, ISIN), keep all groups.\n const isAlphanumeric = parts.some(\n (p) => /[a-zA-Z]/.test(p) && /\\d/.test(p),\n );\n const groups = parts\n .filter(\n (p) =>\n p.length > 0 && (isAlphanumeric || /\\d/.test(p)),\n )\n .map((p) => p.length);\n\n return groups.length > 1 ? groups : null;\n};\n\n/**\n * Detect if this validator uses a known prefix\n * (e.g., \"CZ\" for DIČ, \"CHE\" for Swiss UID).\n */\nconst inferPrefix = (v: Validator): string | null => {\n const examples = v.examples;\n const first = examples?.[0];\n if (!examples || first === undefined) return null;\n const compact = v.compact(first);\n // Prefix already present in compact form.\n // But only if ALL examples share the same prefix\n // (e.g., \"CHE\" for Swiss UID). If examples have\n // different prefixes (IBAN: GB/DE/FR), there's\n // no fixed prefix — it's part of the value.\n const compactMatch = compact.match(/^([A-Z]+)\\d/);\n const compactPrefix = compactMatch?.[1];\n if (compactPrefix !== undefined && examples.length > 1) {\n const allSame = examples.every((ex) =>\n v.compact(ex).startsWith(compactPrefix),\n );\n if (allSame) return compactPrefix;\n } else if (\n compactPrefix !== undefined &&\n examples.length === 1\n ) {\n return compactPrefix;\n }\n // Prefix added only by format()\n // (e.g., \"DE\" for de.vat, \"CZ\" for cz.dic)\n const formatted = v.format(compact);\n const fmtMatch = formatted.match(/^([A-Z]+)[\\s\\-./]?\\d/);\n const fmtPrefix = fmtMatch?.[1];\n if (\n fmtPrefix !== undefined &&\n !compact.startsWith(fmtPrefix)\n ) {\n return fmtPrefix;\n }\n return null;\n};\n\n/**\n * Character class for a string fragment:\n * `\\d` if all digits, `[A-Z]` if all letters,\n * `[A-Z0-9]` if mixed.\n */\nconst charClassFor = (s: string): string => {\n let hasLetter = false;\n let hasDigit = false;\n for (const ch of s) {\n if (/[a-zA-Z]/.test(ch)) hasLetter = true;\n if (/\\d/.test(ch)) hasDigit = true;\n }\n if (hasLetter && hasDigit) return \"[A-Z0-9]\";\n if (hasLetter) return \"[A-Z]\";\n return \"\\\\d\";\n};\n\n/**\n * Determine the character class needed for the\n * compact form: `\\d` if all digits, `[A-Z0-9]`\n * if alphanumeric, etc.\n */\nconst inferCharClass = (v: Validator): string => {\n if (!v.examples || v.examples.length === 0) {\n return \"\\\\d\";\n }\n const combined = v.examples\n .map((ex) => v.compact(ex))\n .join(\"\");\n return charClassFor(combined);\n};\n\ntype PerGroup = { size: number; charClass: string };\n\n/**\n * Infer per-group sizes AND character classes from\n * format(). Returns groups with per-position char\n * classes, e.g., \"12 010188 M 01 1\" →\n * sizes: [2, 6, 1, 2, 1]\n * classes: [\"\\d\", \"\\d\", \"[A-Z]\", \"\\d\", \"\\d\"]\n *\n * Only returns non-null when per-group classes\n * differ (some groups are letters, some digits).\n * Letter-only groups before the first digit group\n * are treated as prefixes and excluded (handled\n * by inferPrefix separately).\n */\nconst inferPerGroup = (v: Validator): PerGroup[] | null => {\n const first = v.examples?.[0];\n if (first === undefined) return null;\n const compact = v.compact(first);\n const formatted = v.format(compact);\n if (formatted === compact) return null;\n\n // Only applies to mixed validators (compact has\n // both letters and digits in separate positions,\n // like German SVNR \"12010188M011\").\n const compactMixed =\n /[a-zA-Z]/.test(compact) && /\\d/.test(compact);\n if (!compactMixed) return null;\n\n // Also skip if any single part mixes letters and\n // digits (IBAN, ISIN) — inferGroups already\n // handles those correctly with the global class.\n const parts = formatted.split(/[^a-zA-Z0-9]+/);\n const isAlphanumeric = parts.some(\n (p) => /[a-zA-Z]/.test(p) && /\\d/.test(p),\n );\n if (isAlphanumeric) return null;\n\n // Keep digit groups and letter-only groups that\n // appear AFTER the first digit group (embedded\n // letters). Skip letter-only groups before the\n // first digit group (prefix like \"CHE\").\n const filtered: PerGroup[] = [];\n let seenDigitGroup = false;\n for (const p of parts) {\n if (p.length === 0) continue;\n if (/\\d/.test(p)) {\n seenDigitGroup = true;\n filtered.push({\n size: p.length,\n charClass: charClassFor(p),\n });\n } else if (seenDigitGroup) {\n filtered.push({\n size: p.length,\n charClass: charClassFor(p),\n });\n }\n }\n\n if (filtered.length <= 1) return null;\n\n const firstClass = filtered[0]?.charClass;\n const allSame = filtered.every(\n (g) => g.charClass === firstClass,\n );\n if (allSame) return null;\n\n return filtered;\n};\n\n/**\n * Build a group regex from group sizes + char class.\n * [2, 3, 3] with \\d → /\\d{2}[\\s\\-.]?\\d{3}[\\s\\-.]?\\d{3}/\n */\nconst groupsToPattern = (\n groups: number[],\n cc: string,\n): string => groups.map((g) => `${cc}{${g}}`).join(SEP);\n\n/**\n * Build a group regex with per-group char classes.\n * Produces tighter patterns when groups have different\n * character types (e.g., digits vs letters).\n */\nconst groupsToPatternPerClass = (\n groups: readonly { size: number; charClass: string }[],\n): string =>\n groups\n .map(({ size, charClass }) => `${charClass}{${size}}`)\n .join(SEP);\n\n/**\n * Derive a loose candidate-matching regex from\n * a validator. The regex finds potential matches;\n * use `validate()` to confirm.\n *\n * Handles both digit-only (IČO, NIP) and\n * alphanumeric (IBAN, BIC, ISIN, LEI) validators.\n */\nexport const toRegex = (v: Validator): RegExp => {\n const prefix = inferPrefix(v);\n const groups = inferGroups(v);\n const lengths = inferLengths(v);\n const cc = inferCharClass(v);\n\n let pattern: string;\n\n // Use per-group char classes when groups mix\n // digits and letters (e.g., German SVNR:\n // \"12 010188 M 01 1\" → [\\d, \\d, [A-Z], \\d, \\d]).\n // This prevents overly broad [A-Z0-9] from\n // matching all-caps prose as identifiers.\n const perGroup = inferPerGroup(v);\n\n if (perGroup && lengths.length <= 1) {\n pattern = groupsToPatternPerClass(perGroup);\n } else if (groups && lengths.length <= 1) {\n pattern = groupsToPattern(groups, cc);\n } else if (lengths.length === 1) {\n pattern = `${cc}{${lengths[0]}}`;\n } else if (lengths.length > 1) {\n const min = Math.min(...lengths);\n const max = Math.max(...lengths);\n pattern = `${cc}{${min},${max}}`;\n } else {\n pattern = `${cc}{6,20}`;\n }\n\n if (prefix) {\n pattern = `${prefix}${SEP}${pattern}`;\n }\n\n // Word boundary to avoid matching inside\n // larger numbers\n return new RegExp(`(?<!\\\\w)${pattern}(?!\\\\w)`, \"g\");\n};\n\n// ─── Grouped collections ──────────────────────\n\n/**\n * All discovered validators, lazily populated.\n * Import * from \"../src\" would pull everything;\n * instead, callers pass validators explicitly.\n */\n\n/**\n * Build patterns for a list of validators.\n */\nexport const toPatterns = <TValidator extends Validator>(\n validators: readonly TValidator[],\n): ValidatorPattern<TValidator>[] =>\n validators.map((v) => ({\n validator: v,\n regex: toRegex(v),\n }));\n\n/**\n * Filter validators by country code and build\n * patterns.\n */\ntype CountryScopedValidator<\n TValidator extends Validator,\n TCountry extends CountryCode,\n> =\n TValidator extends CountryValidator<\n infer TValidatorCountry,\n infer TParsed\n >\n ? TCountry extends TValidatorCountry\n ? TValidator & CountryValidator<TCountry, TParsed>\n : TValidatorCountry extends TCountry\n ? TValidator\n : never\n : never;\n\nexport const byCountry = <\n TCountry extends CountryCode,\n TValidator extends Validator,\n>(\n country: TCountry,\n validators: readonly TValidator[],\n): ValidatorPattern<\n CountryScopedValidator<TValidator, TCountry>\n>[] => {\n const countryValidators = validators.filter(\n (\n v,\n ): v is CountryScopedValidator<TValidator, TCountry> =>\n v.scope === \"country\" && v.country === country,\n );\n return toPatterns(countryValidators);\n};\n\n/**\n * Filter validators by entity type and build\n * patterns.\n */\nexport const byEntityType = <TValidator extends Validator>(\n entityType: \"person\" | \"company\" | \"any\",\n validators: readonly TValidator[],\n): ValidatorPattern<TValidator>[] =>\n toPatterns(\n validators.filter(\n (v) =>\n entityType === \"any\" ||\n v.entityType === entityType ||\n v.entityType === \"any\",\n ),\n );\n\n/**\n * Build patterns for ALL provided validators.\n */\nexport const allPatterns = <TValidator extends Validator>(\n validators: readonly TValidator[],\n): ValidatorPattern<TValidator>[] => toPatterns(validators);\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"patterns.js","names":[],"sources":["../src/patterns.ts"],"sourcesContent":["import { allValidators } from \"./generated/registry\";\nimport type {\n CountryCode,\n CountryValidator,\n Validator,\n} from \"./types\";\n\nexport type ValidatorPattern<\n TValidator extends Validator = Validator,\n> = {\n validator: TValidator;\n regex: RegExp;\n};\n\nexport const toRegex = (validator: Validator): RegExp => {\n if (validator.candidatePattern === undefined) {\n throw new Error(\n `${validator.name} does not define a candidate pattern`,\n );\n }\n return new RegExp(validator.candidatePattern, \"g\");\n};\nexport const toPatterns = <TValidator extends Validator>(\n validators: readonly TValidator[],\n): ValidatorPattern<TValidator>[] =>\n validators\n .filter(\n (validator) =>\n validator.candidatePattern !== undefined,\n )\n .map((validator) => ({\n validator,\n regex: toRegex(validator),\n }));\nexport const byCountry = <TCountry extends CountryCode>(\n country: TCountry,\n) =>\n toPatterns(\n allValidators.filter(\n (validator) =>\n validator.scope === \"country\" &&\n validator.country === country,\n ) as unknown as readonly CountryValidator<TCountry>[],\n );\nexport const byEntityType = (\n entityType: Validator[\"entityType\"],\n) =>\n toPatterns(\n allValidators.filter(\n (validator) => validator.entityType === entityType,\n ),\n );\nexport const allPatterns = () => toPatterns(allValidators);\n"],"mappings":";;AAcA,MAAa,WAAW,cAAiC;CACvD,IAAI,UAAU,qBAAqB,KAAA,GACjC,MAAM,IAAI,MACR,GAAG,UAAU,KAAK,qCACpB;CAEF,OAAO,IAAI,OAAO,UAAU,kBAAkB,GAAG;AACnD;AACA,MAAa,cACX,eAEA,WACG,QACE,cACC,UAAU,qBAAqB,KAAA,CACnC,CAAC,CACA,KAAK,eAAe;CACnB;CACA,OAAO,QAAQ,SAAS;AAC1B,EAAE;AACN,MAAa,aACX,YAEA,WACE,cAAc,QACX,cACC,UAAU,UAAU,aACpB,UAAU,YAAY,OAC1B,CACF;AACF,MAAa,gBACX,eAEA,WACE,cAAc,QACX,cAAc,UAAU,eAAe,UAC1C,CACF;AACF,MAAa,oBAAoB,WAAW,aAAa"}
|