@vtex/country-forms 1.1.0 → 1.2.0
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/CHANGELOG.md +29 -1
- package/dist/{BRA-PMVV6KOM.js → BRA-CWGYPPBD.js} +43 -27
- package/dist/BRA-CWGYPPBD.js.map +1 -0
- package/dist/{BRA-ZBZXE5II.mjs → BRA-R2DBJTZ2.mjs} +43 -27
- package/dist/BRA-R2DBJTZ2.mjs.map +1 -0
- package/dist/CAN-RDQPFPZU.mjs +127 -0
- package/dist/CAN-RDQPFPZU.mjs.map +1 -0
- package/dist/CAN-ZJQJFUW4.js +129 -0
- package/dist/CAN-ZJQJFUW4.js.map +1 -0
- package/dist/MEX-6CJCALY3.js +125 -0
- package/dist/MEX-6CJCALY3.js.map +1 -0
- package/dist/MEX-ZQL7ZS3G.mjs +123 -0
- package/dist/MEX-ZQL7ZS3G.mjs.map +1 -0
- package/dist/USA-2QW25XAI.mjs +128 -0
- package/dist/USA-2QW25XAI.mjs.map +1 -0
- package/dist/USA-MWP4SDGW.js +130 -0
- package/dist/USA-MWP4SDGW.js.map +1 -0
- package/dist/{bra-MHTXSNLA.js → bra-DQO5W7HB.js} +7 -15
- package/dist/bra-DQO5W7HB.js.map +1 -0
- package/dist/{bra-ILOTR4AN.mjs → bra-MJUXI46I.mjs} +4 -15
- package/dist/bra-MJUXI46I.mjs.map +1 -0
- package/dist/can-3MOZIOGB.js +65 -0
- package/dist/can-3MOZIOGB.js.map +1 -0
- package/dist/can-DKTB2M6I.mjs +41 -0
- package/dist/can-DKTB2M6I.mjs.map +1 -0
- package/dist/can-LLWX4LC2.js +48 -0
- package/dist/can-LLWX4LC2.js.map +1 -0
- package/dist/can-OONXPDKH.mjs +59 -0
- package/dist/can-OONXPDKH.mjs.map +1 -0
- package/dist/chunk-B2XPLIJU.mjs +19 -0
- package/dist/chunk-B2XPLIJU.mjs.map +1 -0
- package/dist/chunk-ZQQPNXLP.js +21 -0
- package/dist/chunk-ZQQPNXLP.js.map +1 -0
- package/dist/common-E4IN3G46.mjs +4 -0
- package/dist/common-E4IN3G46.mjs.map +1 -0
- package/dist/common-LFDTUEMM.js +13 -0
- package/dist/common-LFDTUEMM.js.map +1 -0
- package/dist/{en-US-YW7UYXNB.mjs → en-US-KHII5INO.mjs} +22 -2
- package/dist/en-US-KHII5INO.mjs.map +1 -0
- package/dist/{en-US-RLEM27ZZ.js → en-US-RCNO3BZC.js} +22 -2
- package/dist/en-US-RCNO3BZC.js.map +1 -0
- package/dist/{es-MX-K5MWKMJW.js → es-MX-IGOEW2P4.js} +22 -2
- package/dist/es-MX-IGOEW2P4.js.map +1 -0
- package/dist/{es-MX-AGRGVXRK.mjs → es-MX-R24GRBU5.mjs} +22 -2
- package/dist/es-MX-R24GRBU5.mjs.map +1 -0
- package/dist/{fr-FR-KWQ3MPP5.mjs → fr-FR-N4WJAN23.mjs} +22 -2
- package/dist/fr-FR-N4WJAN23.mjs.map +1 -0
- package/dist/{fr-FR-LJIPE6BH.js → fr-FR-WZBI6O4O.js} +22 -2
- package/dist/fr-FR-WZBI6O4O.js.map +1 -0
- package/dist/index.d.mts +178 -7
- package/dist/index.d.ts +178 -7
- package/dist/index.js +109 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -38
- package/dist/index.mjs.map +1 -1
- package/dist/mex-AMEX6IHY.mjs +108 -0
- package/dist/mex-AMEX6IHY.mjs.map +1 -0
- package/dist/mex-DYWVMWB6.js +38 -0
- package/dist/mex-DYWVMWB6.js.map +1 -0
- package/dist/mex-VX3Y5I6I.mjs +33 -0
- package/dist/mex-VX3Y5I6I.mjs.map +1 -0
- package/dist/mex-Y56WV2L7.js +114 -0
- package/dist/mex-Y56WV2L7.js.map +1 -0
- package/dist/{pt-BR-P2RZ3X3H.mjs → pt-BR-PIBP3JHL.mjs} +25 -2
- package/dist/pt-BR-PIBP3JHL.mjs.map +1 -0
- package/dist/{pt-BR-74IZNREP.js → pt-BR-ZDM55ITO.js} +25 -2
- package/dist/pt-BR-ZDM55ITO.js.map +1 -0
- package/dist/usa-AC7YPVS3.mjs +52 -0
- package/dist/usa-AC7YPVS3.mjs.map +1 -0
- package/dist/usa-B6NCCTF6.js +61 -0
- package/dist/usa-B6NCCTF6.js.map +1 -0
- package/dist/usa-LOOP7MRM.mjs +55 -0
- package/dist/usa-LOOP7MRM.mjs.map +1 -0
- package/dist/usa-OQ44AFEI.js +61 -0
- package/dist/usa-OQ44AFEI.js.map +1 -0
- package/package.json +1 -1
- package/dist/BRA-PMVV6KOM.js.map +0 -1
- package/dist/BRA-ZBZXE5II.mjs.map +0 -1
- package/dist/bra-ILOTR4AN.mjs.map +0 -1
- package/dist/bra-MHTXSNLA.js.map +0 -1
- package/dist/can-7TMYDEJF.mjs +0 -17
- package/dist/can-7TMYDEJF.mjs.map +0 -1
- package/dist/can-B5ME2ZFN.js +0 -20
- package/dist/can-B5ME2ZFN.js.map +0 -1
- package/dist/can-FGNN5MZS.mjs +0 -19
- package/dist/can-FGNN5MZS.mjs.map +0 -1
- package/dist/can-LLJ4A5Y5.js +0 -21
- package/dist/can-LLJ4A5Y5.js.map +0 -1
- package/dist/en-US-RLEM27ZZ.js.map +0 -1
- package/dist/en-US-YW7UYXNB.mjs.map +0 -1
- package/dist/es-MX-AGRGVXRK.mjs.map +0 -1
- package/dist/es-MX-K5MWKMJW.js.map +0 -1
- package/dist/fr-FR-KWQ3MPP5.mjs.map +0 -1
- package/dist/fr-FR-LJIPE6BH.js.map +0 -1
- package/dist/mex-5BKCF6LS.js +0 -21
- package/dist/mex-5BKCF6LS.js.map +0 -1
- package/dist/mex-G3HMNBBF.mjs +0 -19
- package/dist/mex-G3HMNBBF.mjs.map +0 -1
- package/dist/pt-BR-74IZNREP.js.map +0 -1
- package/dist/pt-BR-P2RZ3X3H.mjs.map +0 -1
- package/dist/usa-3AM7UFVG.js +0 -20
- package/dist/usa-3AM7UFVG.js.map +0 -1
- package/dist/usa-I7DK2CTL.m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AA,CAA6B,IAAA,CAAK,GAAG,CAAA,EAAG;AAC3C,IAAA,OAAO,kCAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,mBAAA,CAAoB,GAAA,CAAI,MAAM,CAAA,EAAG,EAAE,CAAC,CAAA,EAAG;AAC1C,IAAA,OAAO,kCAAA;AAAA,EACT;AACA,EAAA,IAAI,uBAAuB,GAAA,CAAI,GAAA,CAAI,MAAM,CAAA,EAAG,CAAC,CAAC,CAAA,EAAG;AAC/C,IAAA,OAAO,kCAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;AAmBO,SAAS,qBAAqB,KAAA,EAAiC;AACpE,EAAA,MAAM,MAAM,KAAA,CAAM,WAAA,EAAY,CAAE,OAAA,CAAQ,cAAc,EAAE,CAAA;AAExD,EAAA,IAAI,CAAC,4BAAA,CAA6B,IAAA,CAAK,GAAG,CAAA,EAAG;AAC3C,IAAA,OAAO,kCAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,mBAAA,CAAoB,GAAA,CAAI,MAAM,CAAA,EAAG,CAAC,CAAC,CAAA,EAAG;AACzC,IAAA,OAAO,kCAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;AAEAA,kCAAA,CAAkB,yBAAyB,qBAAqB,CAAA;AAChEA,kCAAA,CAAkB,oBAAoB,gBAAgB,CAAA;AACtDA,kCAAA,CAAkB,eAAe,WAAW,CAAA;AAC5CA,kCAAA,CAAkB,wBAAwB,oBAAoB,CAAA","file":"mex-Y56WV2L7.js","sourcesContent":["/**\n * @module rules/validators/mex\n *\n * Synchronous validators for Mexican address and personal-data fields.\n * Importing this module registers all validators in the shared registry.\n *\n * Registered refs:\n * - `\"validatePostalCodeMEX\"` — Mexican Código Postal (CP) format validation\n * - `\"validatePhoneMEX\"` — Mexican phone number (10 digits, optional `+52`)\n * - `\"validateRFC\"` — RFC for individuals / persona física (13 chars)\n * - `\"validateRFCCorporate\"` — RFC for companies / persona moral (12 chars)\n */\n\nimport { registerValidator } from './index'\n\n/**\n * Structural Mexican phone check: 10 national digits whose first digit is 2-9\n * (Mexican geographic and mobile numbers never start with 0 or 1). Applied to\n * the digits-only string after stripping the optional `+52` country code\n * (see {@link unformatPhoneMEXDigits}).\n *\n * We validate the *structure* on purpose instead of an allowlist of IFT area\n * codes. A hardcoded allowlist (the previous ~4 KB regex) silently rejects valid\n * numbers from regions whose area codes the IFT allocated after the list was\n * written, with no actionable error and no mechanism to flag the staleness —\n * blocking legitimate submissions in production. Structural validation accepts\n * any future allocation while still rejecting the impossible leading `0`/`1`.\n *\n * The 2-digit-metro vs 3-digit-area split only affects *display* grouping and\n * lives solely in `rules/masks/mex.ts`; validation does not depend on it, so the\n * two files no longer need to share an area-code list.\n */\nconst PHONE_MEX_REGEX = /^[2-9]\\d{9}$/\n\n/**\n * RFC name prefixes (first 4 letters of a persona física RFC) that the SAT\n * replaces because they spell inappropriate words. A real RFC never starts with\n * these, so they are rejected.\n */\nconst RFC_INCONVENIENT_WORDS = new Set([\n 'BUEI', 'BUEY', 'CACA', 'CACO', 'CAGA', 'CAGO', 'CAKA', 'CAKO', 'COGE', 'COJA',\n 'COJE', 'COJI', 'COJO', 'CULO', 'FETO', 'GUEY', 'JOTO', 'KACA', 'KACO', 'KAGA',\n 'KAGO', 'KAKA', 'KOGE', 'KOJO', 'KULO', 'MAME', 'MAMO', 'MEAR', 'MEAS', 'MEON',\n 'MION', 'MOCO', 'MULA', 'PEDA', 'PEDO', 'PENE', 'PUTA', 'PUTO', 'QULO', 'RATA',\n 'RUIN',\n])\n\n/**\n * Strips non-digits and the optional leading `52` country code, returning the\n * 10-digit national number when possible.\n *\n * NOTE: this mirrors `unformatPhoneMEX` in `rules/masks/mex.ts` by design. The\n * duplication is intentional: validators and masks are independent modules that\n * load separately (a consumer can import one without the other, preserving\n * tree-shaking and module isolation). Validators must NOT import from masks, so\n * the small amount of shared logic is copied rather than shared. It is exported\n * so a cross-module test can assert that both copies stay in sync — keep both\n * implementations identical if the unformat rule changes.\n */\nexport function unformatPhoneMEXDigits(value: string): string {\n const digits = value.replace(/\\D/g, '')\n if (digits.length > 10 && digits.startsWith('52')) {\n return digits.slice(2)\n }\n return digits\n}\n\n/**\n * Validates a Mexican Código Postal (CP).\n *\n * Rules:\n * - Must be exactly 5 digits (leading zeros are valid, e.g. `\"06600\"`).\n * - Numeric value must be in the range 01000–99999.\n * Codes 00001–00999 are not assigned by Correos de México.\n *\n * @param value - The postal code string to validate (digits only, no mask)\n * @returns `true` when valid, or an i18n error key string when invalid\n */\nexport function validatePostalCodeMEX(value: string): boolean | string {\n const trimmed = value.trim()\n\n if (!/^\\d{5}$/.test(trimmed)) {\n return 'country-forms.validation.postalCode.MEX'\n }\n\n const n = parseInt(trimmed, 10)\n\n if (n < 1000) {\n return 'country-forms.validation.postalCode.MEX'\n }\n\n return true\n}\n\n/**\n * Validates a Mexican phone number.\n *\n * Accepts masked (`\"(55) 1234 5678\"`) and unmasked (`\"5512345678\"`) forms, as\n * well as numbers prefixed with the country code `+52` / `52`. Non-digit\n * characters are stripped before validation.\n *\n * Rules:\n * - After stripping the optional country code, the number must be 10 digits.\n * - Structural: the first digit must be 2-9 (Mexican numbers never start with\n * 0 or 1; see {@link PHONE_MEX_REGEX} for why this replaces an allowlist).\n *\n * @param value - Phone string to validate (with or without mask or `+52` prefix)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validatePhoneMEX(value: string): boolean | string {\n const phone = unformatPhoneMEXDigits(value)\n if (!PHONE_MEX_REGEX.test(phone)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n/**\n * Range-checks the 6 date digits (`YYMMDD`) embedded in an RFC: month must be\n * 01–12 and day 01–31.\n *\n * This is a **range** check, not a calendar check — it does not account for month\n * length or leap years (e.g. `\"000230\"` / Feb 30 passes). It exists to reject\n * obviously impossible dates the `\\d{6}` pattern would otherwise accept, such as\n * `000000` (month/day 00) or `001399` (month 13, day 99).\n *\n * @param yymmdd - The 6 date digits from the RFC\n * @returns `true` when the month and day fall within plausible ranges\n */\nfunction hasPlausibleRFCDate(yymmdd: string): boolean {\n const month = Number(yymmdd.slice(2, 4))\n const day = Number(yymmdd.slice(4, 6))\n return month >= 1 && month <= 12 && day >= 1 && day <= 31\n}\n\n/**\n * Validates a Mexican RFC for an individual (persona física).\n *\n * Accepts masked and unmasked forms; case-insensitive (normalized to uppercase,\n * non-alphanumeric characters stripped).\n *\n * Rules:\n * - Format: 4 letters + 6 digits (birth date) + 3 alphanumeric (homoclave) = 13 chars.\n * - The 6 date digits (`YYMMDD`) must have a plausible month (01–12) and day (01–31).\n * - The 4-letter name prefix must not be one of the SAT's inconvenient-word list.\n *\n * Limitation: the date is only **range**-checked, not calendar-validated (Feb 30\n * passes), and the homoclave check digit is **not** verified (its algorithm is\n * not public). Treat this as a format + plausible-date + blacklist check.\n *\n * @param value - RFC string to validate (with or without separators)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateRFC(value: string): boolean | string {\n const rfc = value.toUpperCase().replace(/[^A-Z0-9]/g, '')\n\n if (!/^[A-Z]{4}\\d{6}[A-Z0-9]{3}$/.test(rfc)) {\n return 'country-forms.validation.invalid'\n }\n if (!hasPlausibleRFCDate(rfc.slice(4, 10))) {\n return 'country-forms.validation.invalid'\n }\n if (RFC_INCONVENIENT_WORDS.has(rfc.slice(0, 4))) {\n return 'country-forms.validation.invalid'\n }\n\n return true\n}\n\n/**\n * Validates a Mexican RFC for a company (persona moral).\n *\n * Accepts masked and unmasked forms; case-insensitive (normalized to uppercase,\n * non-alphanumeric characters stripped).\n *\n * Rules:\n * - Format: 3 letters + 6 digits (incorporation date) + 3 alphanumeric (homoclave) = 12 chars.\n * - The 6 date digits (`YYMMDD`) must have a plausible month (01–12) and day (01–31).\n *\n * Limitation: the date is only **range**-checked, not calendar-validated (Feb 30\n * passes), and the homoclave check digit is **not** verified, so this is a\n * format + plausible-date check only.\n *\n * @param value - RFC string to validate (with or without separators)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateRFCCorporate(value: string): boolean | string {\n const rfc = value.toUpperCase().replace(/[^A-Z0-9]/g, '')\n\n if (!/^[A-Z]{3}\\d{6}[A-Z0-9]{3}$/.test(rfc)) {\n return 'country-forms.validation.invalid'\n }\n if (!hasPlausibleRFCDate(rfc.slice(3, 9))) {\n return 'country-forms.validation.invalid'\n }\n\n return true\n}\n\nregisterValidator('validatePostalCodeMEX', validatePostalCodeMEX)\nregisterValidator('validatePhoneMEX', validatePhoneMEX)\nregisterValidator('validateRFC', validateRFC)\nregisterValidator('validateRFCCorporate', validateRFCCorporate)\n"]}
|
|
@@ -22,6 +22,8 @@ var bundle = {
|
|
|
22
22
|
"country-forms.personal-data.contactType.phone": "Telefone",
|
|
23
23
|
"country-forms.personal-data.email.label": "E-mail",
|
|
24
24
|
"country-forms.personal-data.phone.label": "Telefone",
|
|
25
|
+
"country-forms.personal-data.document.label": "Documento",
|
|
26
|
+
"country-forms.personal-data.documentType.label": "Tipo de documento",
|
|
25
27
|
// ── Personal data labels (BRA) ────────────────────────────────────────────
|
|
26
28
|
"country-forms.personal-data.personType.label": "Tipo de pessoa",
|
|
27
29
|
"country-forms.personal-data.personType.individual": "Pessoa f\xEDsica",
|
|
@@ -33,6 +35,27 @@ var bundle = {
|
|
|
33
35
|
"country-forms.personal-data.cnpj.label": "CNPJ",
|
|
34
36
|
"country-forms.personal-data.cnpj.placeholder": "ex: 11.222.333/0001-81",
|
|
35
37
|
"country-forms.personal-data.phone.placeholder.BRA": "ex: (11) 99999-9999",
|
|
38
|
+
// ── Personal data labels (USA) ────────────────────────────────────────────
|
|
39
|
+
// SSN/EIN are US federal identifiers with no official Portuguese name. We
|
|
40
|
+
// translate the descriptor for readability and keep the recognizable US
|
|
41
|
+
// acronym in parentheses, matching the es-MX and fr-FR bundles.
|
|
42
|
+
"country-forms.personal-data.ssn.label": "N\xFAmero de Seguro Social (SSN)",
|
|
43
|
+
"country-forms.personal-data.ssn.placeholder": "ex: 123-45-6789",
|
|
44
|
+
"country-forms.personal-data.ein.label": "N\xFAmero de Identifica\xE7\xE3o do Empregador (EIN)",
|
|
45
|
+
"country-forms.personal-data.ein.placeholder": "ex: 12-3456789",
|
|
46
|
+
"country-forms.personal-data.phone.placeholder.USA": "ex: (201) 555-0123",
|
|
47
|
+
// ── Personal data labels (CAN) ────────────────────────────────────────────
|
|
48
|
+
"country-forms.personal-data.sin.label": "N\xFAmero de Seguro Social (SIN)",
|
|
49
|
+
"country-forms.personal-data.sin.placeholder": "ex: 046-454-286",
|
|
50
|
+
"country-forms.personal-data.bn.label": "N\xFAmero de Empresa (BN)",
|
|
51
|
+
"country-forms.personal-data.bn.placeholder": "ex: 123456789",
|
|
52
|
+
"country-forms.personal-data.phone.placeholder.CAN": "ex: 613-555-0123",
|
|
53
|
+
// ── Personal data labels (MEX) ────────────────────────────────────────────
|
|
54
|
+
"country-forms.personal-data.rfc.label": "RFC (pessoa f\xEDsica)",
|
|
55
|
+
"country-forms.personal-data.rfc.placeholder": "ex: XAXX010101000",
|
|
56
|
+
"country-forms.personal-data.rfcCorporate.label": "RFC (pessoa jur\xEDdica)",
|
|
57
|
+
"country-forms.personal-data.rfcCorporate.placeholder": "ex: ABC010101AB1",
|
|
58
|
+
"country-forms.personal-data.phone.placeholder.MEX": "ex: (55) 1234 5678",
|
|
36
59
|
// ── Validation messages ───────────────────────────────────────────────────
|
|
37
60
|
"country-forms.validation.required": "Campo obrigat\xF3rio. Preencha {fieldName}.",
|
|
38
61
|
"country-forms.validation.invalid": "{fieldName} inv\xE1lido. Preencha o campo {fieldName} novamente.",
|
|
@@ -45,5 +68,5 @@ var bundle = {
|
|
|
45
68
|
var pt_BR_default = bundle;
|
|
46
69
|
|
|
47
70
|
export { pt_BR_default as default };
|
|
48
|
-
//# sourceMappingURL=pt-BR-
|
|
49
|
-
//# sourceMappingURL=pt-BR-
|
|
71
|
+
//# sourceMappingURL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DAAA,EAAqD,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrD,uCAAA,EAAyC,kCAAA;AAAA,EACzC,6CAAA,EAA+C,iBAAA;AAAA,EAC/C,uCAAA,EAAyC,sDAAA;AAAA,EACzC,6CAAA,EAA+C,gBAAA;AAAA,EAC/C,mDAAA,EAAqD,oBAAA;AAAA;AAAA,EAGrD,uCAAA,EAAyC,kCAAA;AAAA,EACzC,6CAAA,EAA+C,iBAAA;AAAA,EAC/C,sCAAA,EAAwC,2BAAA;AAAA,EACxC,4CAAA,EAA8C,eAAA;AAAA,EAC9C,mDAAA,EAAqD,kBAAA;AAAA;AAAA,EAGrD,uCAAA,EAAyC,wBAAA;AAAA,EACzC,6CAAA,EAA+C,mBAAA;AAAA,EAC/C,gDAAA,EAAkD,0BAAA;AAAA,EAClD,sDAAA,EAAwD,kBAAA;AAAA,EACxD,mDAAA,EAAqD,oBAAA;AAAA;AAAA,EAGrD,mCAAA,EAAqC,6CAAA;AAAA,EACrC,kCAAA,EAAoC,kEAAA;AAAA,EACpC,oCAAA,EAAsC,oDAAA;AAAA,EACtC,yCAAA,EAA2C,0CAAA;AAAA,EAC3C,yCAAA,EAA2C,2CAAA;AAAA,EAC3C,yCAAA,EAA2C,qDAAA;AAAA,EAC3C,yCAAA,EAA2C;AAC7C,CAAA;AAEA,IAAO,aAAA,GAAQ","file":"pt-BR-PIBP3JHL.mjs","sourcesContent":["/**\n * Portuguese (pt-BR) i18n bundle — Brazilian Portuguese.\n */\nimport type { I18nBundle } from '../../types/i18n'\n\nconst bundle: I18nBundle = {\n // ── Address labels ────────────────────────────────────────────────────────\n 'country-forms.address.postalCode.label': 'CEP',\n 'country-forms.address.street.label': 'Endereço',\n 'country-forms.address.street.placeholder': 'Endereço completo',\n 'country-forms.address.number.label': 'Número',\n 'country-forms.address.complement.label': 'Complemento (opcional)',\n 'country-forms.address.neighborhood.label': 'Bairro',\n 'country-forms.address.city.label': 'Cidade',\n 'country-forms.address.state.label': 'Estado',\n // ── Address placeholders (per country) ────────────────────────────────────\n 'country-forms.address.postalCode.placeholder.BRA': 'ex: 01310-100',\n 'country-forms.address.postalCode.placeholder.USA': 'ex: 10001 ou 10001-1234',\n 'country-forms.address.postalCode.placeholder.CAN': 'ex: K1A 0A9',\n 'country-forms.address.postalCode.placeholder.MEX': 'ex: 06600',\n\n // ── Personal data labels (fallback) ─────────────────────────────────────\n 'country-forms.personal-data.firstName.label': 'Nome',\n 'country-forms.personal-data.lastName.label': 'Sobrenome',\n 'country-forms.personal-data.contactType.label': 'Contato preferido',\n 'country-forms.personal-data.contactType.email': 'E-mail',\n 'country-forms.personal-data.contactType.phone': 'Telefone',\n 'country-forms.personal-data.email.label': 'E-mail',\n 'country-forms.personal-data.phone.label': 'Telefone',\n 'country-forms.personal-data.document.label': 'Documento',\n 'country-forms.personal-data.documentType.label': 'Tipo de documento',\n\n // ── Personal data labels (BRA) ────────────────────────────────────────────\n 'country-forms.personal-data.personType.label': 'Tipo de pessoa',\n 'country-forms.personal-data.personType.individual': 'Pessoa física',\n 'country-forms.personal-data.personType.business': 'Pessoa jurídica',\n 'country-forms.personal-data.firstName.label.individual': 'Nome',\n 'country-forms.personal-data.firstName.label.business': 'Razão social',\n 'country-forms.personal-data.cpf.label': 'CPF',\n 'country-forms.personal-data.cpf.placeholder': 'ex: 123.456.789-09',\n 'country-forms.personal-data.cnpj.label': 'CNPJ',\n 'country-forms.personal-data.cnpj.placeholder': 'ex: 11.222.333/0001-81',\n 'country-forms.personal-data.phone.placeholder.BRA': 'ex: (11) 99999-9999',\n\n // ── Personal data labels (USA) ────────────────────────────────────────────\n // SSN/EIN are US federal identifiers with no official Portuguese name. We\n // translate the descriptor for readability and keep the recognizable US\n // acronym in parentheses, matching the es-MX and fr-FR bundles.\n 'country-forms.personal-data.ssn.label': 'Número de Seguro Social (SSN)',\n 'country-forms.personal-data.ssn.placeholder': 'ex: 123-45-6789',\n 'country-forms.personal-data.ein.label': 'Número de Identificação do Empregador (EIN)',\n 'country-forms.personal-data.ein.placeholder': 'ex: 12-3456789',\n 'country-forms.personal-data.phone.placeholder.USA': 'ex: (201) 555-0123',\n\n // ── Personal data labels (CAN) ────────────────────────────────────────────\n 'country-forms.personal-data.sin.label': 'Número de Seguro Social (SIN)',\n 'country-forms.personal-data.sin.placeholder': 'ex: 046-454-286',\n 'country-forms.personal-data.bn.label': 'Número de Empresa (BN)',\n 'country-forms.personal-data.bn.placeholder': 'ex: 123456789',\n 'country-forms.personal-data.phone.placeholder.CAN': 'ex: 613-555-0123',\n\n // ── Personal data labels (MEX) ────────────────────────────────────────────\n 'country-forms.personal-data.rfc.label': 'RFC (pessoa física)',\n 'country-forms.personal-data.rfc.placeholder': 'ex: XAXX010101000',\n 'country-forms.personal-data.rfcCorporate.label': 'RFC (pessoa jurídica)',\n 'country-forms.personal-data.rfcCorporate.placeholder': 'ex: ABC010101AB1',\n 'country-forms.personal-data.phone.placeholder.MEX': 'ex: (55) 1234 5678',\n\n // ── Validation messages ───────────────────────────────────────────────────\n 'country-forms.validation.required': 'Campo obrigatório. Preencha {fieldName}.',\n 'country-forms.validation.invalid': '{fieldName} inválido. Preencha o campo {fieldName} novamente.',\n 'country-forms.validation.maxLength': '{fieldName} deve ter até {maxLength} caracteres',\n 'country-forms.validation.postalCode.BRA': 'Informe um CEP válido (ex: 01310-100)',\n 'country-forms.validation.postalCode.USA': 'Informe um ZIP code válido (ex: 10001)',\n 'country-forms.validation.postalCode.CAN': 'Informe um código postal válido (ex: K1A 0A9)',\n 'country-forms.validation.postalCode.MEX': 'Informe um Código Postal válido (ex: 06600)',\n}\n\nexport default bundle\n"]}
|
|
@@ -24,6 +24,8 @@ var bundle = {
|
|
|
24
24
|
"country-forms.personal-data.contactType.phone": "Telefone",
|
|
25
25
|
"country-forms.personal-data.email.label": "E-mail",
|
|
26
26
|
"country-forms.personal-data.phone.label": "Telefone",
|
|
27
|
+
"country-forms.personal-data.document.label": "Documento",
|
|
28
|
+
"country-forms.personal-data.documentType.label": "Tipo de documento",
|
|
27
29
|
// ── Personal data labels (BRA) ────────────────────────────────────────────
|
|
28
30
|
"country-forms.personal-data.personType.label": "Tipo de pessoa",
|
|
29
31
|
"country-forms.personal-data.personType.individual": "Pessoa f\xEDsica",
|
|
@@ -35,6 +37,27 @@ var bundle = {
|
|
|
35
37
|
"country-forms.personal-data.cnpj.label": "CNPJ",
|
|
36
38
|
"country-forms.personal-data.cnpj.placeholder": "ex: 11.222.333/0001-81",
|
|
37
39
|
"country-forms.personal-data.phone.placeholder.BRA": "ex: (11) 99999-9999",
|
|
40
|
+
// ── Personal data labels (USA) ────────────────────────────────────────────
|
|
41
|
+
// SSN/EIN are US federal identifiers with no official Portuguese name. We
|
|
42
|
+
// translate the descriptor for readability and keep the recognizable US
|
|
43
|
+
// acronym in parentheses, matching the es-MX and fr-FR bundles.
|
|
44
|
+
"country-forms.personal-data.ssn.label": "N\xFAmero de Seguro Social (SSN)",
|
|
45
|
+
"country-forms.personal-data.ssn.placeholder": "ex: 123-45-6789",
|
|
46
|
+
"country-forms.personal-data.ein.label": "N\xFAmero de Identifica\xE7\xE3o do Empregador (EIN)",
|
|
47
|
+
"country-forms.personal-data.ein.placeholder": "ex: 12-3456789",
|
|
48
|
+
"country-forms.personal-data.phone.placeholder.USA": "ex: (201) 555-0123",
|
|
49
|
+
// ── Personal data labels (CAN) ────────────────────────────────────────────
|
|
50
|
+
"country-forms.personal-data.sin.label": "N\xFAmero de Seguro Social (SIN)",
|
|
51
|
+
"country-forms.personal-data.sin.placeholder": "ex: 046-454-286",
|
|
52
|
+
"country-forms.personal-data.bn.label": "N\xFAmero de Empresa (BN)",
|
|
53
|
+
"country-forms.personal-data.bn.placeholder": "ex: 123456789",
|
|
54
|
+
"country-forms.personal-data.phone.placeholder.CAN": "ex: 613-555-0123",
|
|
55
|
+
// ── Personal data labels (MEX) ────────────────────────────────────────────
|
|
56
|
+
"country-forms.personal-data.rfc.label": "RFC (pessoa f\xEDsica)",
|
|
57
|
+
"country-forms.personal-data.rfc.placeholder": "ex: XAXX010101000",
|
|
58
|
+
"country-forms.personal-data.rfcCorporate.label": "RFC (pessoa jur\xEDdica)",
|
|
59
|
+
"country-forms.personal-data.rfcCorporate.placeholder": "ex: ABC010101AB1",
|
|
60
|
+
"country-forms.personal-data.phone.placeholder.MEX": "ex: (55) 1234 5678",
|
|
38
61
|
// ── Validation messages ───────────────────────────────────────────────────
|
|
39
62
|
"country-forms.validation.required": "Campo obrigat\xF3rio. Preencha {fieldName}.",
|
|
40
63
|
"country-forms.validation.invalid": "{fieldName} inv\xE1lido. Preencha o campo {fieldName} novamente.",
|
|
@@ -47,5 +70,5 @@ var bundle = {
|
|
|
47
70
|
var pt_BR_default = bundle;
|
|
48
71
|
|
|
49
72
|
module.exports = pt_BR_default;
|
|
50
|
-
//# sourceMappingURL=pt-BR-
|
|
51
|
-
//# sourceMappingURL=pt-BR-
|
|
73
|
+
//# sourceMappingURL=pt-BR-ZDM55ITO.js.map
|
|
74
|
+
//# sourceMappingURL=pt-BR-ZDM55ITO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/messages/pt-BR.ts"],"names":[],"mappings":";;;AAKA,IAAM,MAAA,GAAqB;AAAA;AAAA,EAEzB,wCAAA,EAA0C,KAAA;AAAA,EAC1C,oCAAA,EAAsC,aAAA;AAAA,EACtC,0CAAA,EAA4C,sBAAA;AAAA,EAC5C,oCAAA,EAAsC,WAAA;AAAA,EACtC,wCAAA,EAA0C,wBAAA;AAAA,EAC1C,0CAAA,EAA4C,QAAA;AAAA,EAC5C,kCAAA,EAAoC,QAAA;AAAA,EACpC,mCAAA,EAAqC,QAAA;AAAA;AAAA,EAErC,kDAAA,EAAoD,eAAA;AAAA,EACpD,kDAAA,EAAoD,yBAAA;AAAA,EACpD,kDAAA,EAAoD,aAAA;AAAA,EACpD,kDAAA,EAAoD,WAAA;AAAA;AAAA,EAGpD,6CAAA,EAA+C,MAAA;AAAA,EAC/C,4C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,oCAAA,EAAsC,oDAAA;AAAA,EACtC,yCAAA,EAA2C,0CAAA;AAAA,EAC3C,yCAAA,EAA2C,2CAAA;AAAA,EAC3C,yCAAA,EAA2C,qDAAA;AAAA,EAC3C,yCAAA,EAA2C;AAC7C,CAAA;AAEA,IAAO,aAAA,GAAQ","file":"pt-BR-ZDM55ITO.js","sourcesContent":["/**\n * Portuguese (pt-BR) i18n bundle — Brazilian Portuguese.\n */\nimport type { I18nBundle } from '../../types/i18n'\n\nconst bundle: I18nBundle = {\n // ── Address labels ────────────────────────────────────────────────────────\n 'country-forms.address.postalCode.label': 'CEP',\n 'country-forms.address.street.label': 'Endereço',\n 'country-forms.address.street.placeholder': 'Endereço completo',\n 'country-forms.address.number.label': 'Número',\n 'country-forms.address.complement.label': 'Complemento (opcional)',\n 'country-forms.address.neighborhood.label': 'Bairro',\n 'country-forms.address.city.label': 'Cidade',\n 'country-forms.address.state.label': 'Estado',\n // ── Address placeholders (per country) ────────────────────────────────────\n 'country-forms.address.postalCode.placeholder.BRA': 'ex: 01310-100',\n 'country-forms.address.postalCode.placeholder.USA': 'ex: 10001 ou 10001-1234',\n 'country-forms.address.postalCode.placeholder.CAN': 'ex: K1A 0A9',\n 'country-forms.address.postalCode.placeholder.MEX': 'ex: 06600',\n\n // ── Personal data labels (fallback) ─────────────────────────────────────\n 'country-forms.personal-data.firstName.label': 'Nome',\n 'country-forms.personal-data.lastName.label': 'Sobrenome',\n 'country-forms.personal-data.contactType.label': 'Contato preferido',\n 'country-forms.personal-data.contactType.email': 'E-mail',\n 'country-forms.personal-data.contactType.phone': 'Telefone',\n 'country-forms.personal-data.email.label': 'E-mail',\n 'country-forms.personal-data.phone.label': 'Telefone',\n 'country-forms.personal-data.document.label': 'Documento',\n 'country-forms.personal-data.documentType.label': 'Tipo de documento',\n\n // ── Personal data labels (BRA) ────────────────────────────────────────────\n 'country-forms.personal-data.personType.label': 'Tipo de pessoa',\n 'country-forms.personal-data.personType.individual': 'Pessoa física',\n 'country-forms.personal-data.personType.business': 'Pessoa jurídica',\n 'country-forms.personal-data.firstName.label.individual': 'Nome',\n 'country-forms.personal-data.firstName.label.business': 'Razão social',\n 'country-forms.personal-data.cpf.label': 'CPF',\n 'country-forms.personal-data.cpf.placeholder': 'ex: 123.456.789-09',\n 'country-forms.personal-data.cnpj.label': 'CNPJ',\n 'country-forms.personal-data.cnpj.placeholder': 'ex: 11.222.333/0001-81',\n 'country-forms.personal-data.phone.placeholder.BRA': 'ex: (11) 99999-9999',\n\n // ── Personal data labels (USA) ────────────────────────────────────────────\n // SSN/EIN are US federal identifiers with no official Portuguese name. We\n // translate the descriptor for readability and keep the recognizable US\n // acronym in parentheses, matching the es-MX and fr-FR bundles.\n 'country-forms.personal-data.ssn.label': 'Número de Seguro Social (SSN)',\n 'country-forms.personal-data.ssn.placeholder': 'ex: 123-45-6789',\n 'country-forms.personal-data.ein.label': 'Número de Identificação do Empregador (EIN)',\n 'country-forms.personal-data.ein.placeholder': 'ex: 12-3456789',\n 'country-forms.personal-data.phone.placeholder.USA': 'ex: (201) 555-0123',\n\n // ── Personal data labels (CAN) ────────────────────────────────────────────\n 'country-forms.personal-data.sin.label': 'Número de Seguro Social (SIN)',\n 'country-forms.personal-data.sin.placeholder': 'ex: 046-454-286',\n 'country-forms.personal-data.bn.label': 'Número de Empresa (BN)',\n 'country-forms.personal-data.bn.placeholder': 'ex: 123456789',\n 'country-forms.personal-data.phone.placeholder.CAN': 'ex: 613-555-0123',\n\n // ── Personal data labels (MEX) ────────────────────────────────────────────\n 'country-forms.personal-data.rfc.label': 'RFC (pessoa física)',\n 'country-forms.personal-data.rfc.placeholder': 'ex: XAXX010101000',\n 'country-forms.personal-data.rfcCorporate.label': 'RFC (pessoa jurídica)',\n 'country-forms.personal-data.rfcCorporate.placeholder': 'ex: ABC010101AB1',\n 'country-forms.personal-data.phone.placeholder.MEX': 'ex: (55) 1234 5678',\n\n // ── Validation messages ───────────────────────────────────────────────────\n 'country-forms.validation.required': 'Campo obrigatório. Preencha {fieldName}.',\n 'country-forms.validation.invalid': '{fieldName} inválido. Preencha o campo {fieldName} novamente.',\n 'country-forms.validation.maxLength': '{fieldName} deve ter até {maxLength} caracteres',\n 'country-forms.validation.postalCode.BRA': 'Informe um CEP válido (ex: 01310-100)',\n 'country-forms.validation.postalCode.USA': 'Informe um ZIP code válido (ex: 10001)',\n 'country-forms.validation.postalCode.CAN': 'Informe um código postal válido (ex: K1A 0A9)',\n 'country-forms.validation.postalCode.MEX': 'Informe um Código Postal válido (ex: 06600)',\n}\n\nexport default bundle\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { registerMask } from './chunk-BMZHOWIP.mjs';
|
|
2
|
+
|
|
3
|
+
// src/rules/masks/usa.ts
|
|
4
|
+
function formatZIP(value) {
|
|
5
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
6
|
+
if (digits.length === 5) return digits;
|
|
7
|
+
if (digits.length === 9) return `${digits.slice(0, 5)}-${digits.slice(5)}`;
|
|
8
|
+
return digits;
|
|
9
|
+
}
|
|
10
|
+
function unformatZIP(value) {
|
|
11
|
+
return value.replace(/\D/g, "");
|
|
12
|
+
}
|
|
13
|
+
function formatPhoneUSA(value) {
|
|
14
|
+
const phone = unformatPhoneUSA(value);
|
|
15
|
+
if (phone.length !== 10) return phone;
|
|
16
|
+
return `(${phone.slice(0, 3)}) ${phone.slice(3, 6)}-${phone.slice(6)}`;
|
|
17
|
+
}
|
|
18
|
+
function unformatPhoneUSA(value) {
|
|
19
|
+
const digits = value.replace(/\D/g, "");
|
|
20
|
+
if (digits.length > 10 && digits.startsWith("1")) {
|
|
21
|
+
return digits.slice(1);
|
|
22
|
+
}
|
|
23
|
+
return digits;
|
|
24
|
+
}
|
|
25
|
+
function formatSSN(value) {
|
|
26
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
27
|
+
if (digits.length !== 9) return digits;
|
|
28
|
+
return `${digits.slice(0, 3)}-${digits.slice(3, 5)}-${digits.slice(5)}`;
|
|
29
|
+
}
|
|
30
|
+
function unformatSSN(value) {
|
|
31
|
+
return value.replace(/\D/g, "");
|
|
32
|
+
}
|
|
33
|
+
function formatEIN(value) {
|
|
34
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
35
|
+
if (digits.length !== 9) return digits;
|
|
36
|
+
return `${digits.slice(0, 2)}-${digits.slice(2)}`;
|
|
37
|
+
}
|
|
38
|
+
function unformatEIN(value) {
|
|
39
|
+
return value.replace(/\D/g, "");
|
|
40
|
+
}
|
|
41
|
+
registerMask("formatZIP", formatZIP);
|
|
42
|
+
registerMask("unformatZIP", unformatZIP);
|
|
43
|
+
registerMask("formatPhoneUSA", formatPhoneUSA);
|
|
44
|
+
registerMask("unformatPhoneUSA", unformatPhoneUSA);
|
|
45
|
+
registerMask("formatSSN", formatSSN);
|
|
46
|
+
registerMask("unformatSSN", unformatSSN);
|
|
47
|
+
registerMask("formatEIN", formatEIN);
|
|
48
|
+
registerMask("unformatEIN", unformatEIN);
|
|
49
|
+
|
|
50
|
+
export { formatEIN, formatPhoneUSA, formatSSN, formatZIP, unformatEIN, unformatPhoneUSA, unformatSSN, unformatZIP };
|
|
51
|
+
//# sourceMappingURL=usa-AC7YPVS3.mjs.map
|
|
52
|
+
//# sourceMappingURL=usa-AC7YPVS3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules/masks/usa.ts"],"names":[],"mappings":";;;AA0BO,SAAS,UAAU,KAAA,EAAuB;AAC/C,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CAAE,KAAA,CAAM,GAAG,CAAC,CAAA;AAElD,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAChC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,GAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAA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AM,CAAC,CAAC,CAAA,CAAA;AACvE;AAQO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChC;AAaO,SAAS,UAAU,KAAA,EAAuB;AAC/C,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CAAE,KAAA,CAAM,GAAG,CAAC,CAAA;AAClD,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAChC,EAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACjD;AAQO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChC;AAEA,YAAA,CAAa,aAAa,SAAS,CAAA;AACnC,YAAA,CAAa,eAAe,WAAW,CAAA;AACvC,YAAA,CAAa,kBAAkB,cAAc,CAAA;AAC7C,YAAA,CAAa,oBAAoB,gBAAgB,CAAA;AACjD,YAAA,CAAa,aAAa,SAAS,CAAA;AACnC,YAAA,CAAa,eAAe,WAAW,CAAA;AACvC,YAAA,CAAa,aAAa,SAAS,CAAA;AACnC,YAAA,CAAa,eAAe,WAAW,CAAA","file":"usa-AC7YPVS3.mjs","sourcesContent":["/**\n * @module rules/masks/usa\n *\n * Format/unformat functions for United States address and personal-data fields.\n * Importing this module registers all masks in the shared registry.\n *\n * Registered refs:\n * - `\"formatZIP\"` / `\"unformatZIP\"` — ZIP+4 display formatting (99999-9999)\n * - `\"formatPhoneUSA\"` / `\"unformatPhoneUSA\"` — US phone ((999) 999-9999)\n * - `\"formatSSN\"` / `\"unformatSSN\"` — Social Security Number (999-99-9999)\n * - `\"formatEIN\"` / `\"unformatEIN\"` — Employer Identification Number (99-9999999)\n */\n\nimport { registerMask } from './index'\n\n/**\n * Formats a raw ZIP code string for display.\n *\n * - Strips non-digit characters and truncates to at most 9 digits\n * - 5 digits → `\"12345\"` (unchanged)\n * - 9 digits → `\"12345-6789\"` (hyphen inserted)\n * - Otherwise returns the digits-only input unchanged\n *\n * @param value - Raw or partially formatted ZIP code\n * @returns Display string with hyphen for ZIP+4, or digits-only for 5-digit ZIP\n */\nexport function formatZIP(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n\n if (digits.length === 5) return digits\n if (digits.length === 9) return `${digits.slice(0, 5)}-${digits.slice(5)}`\n\n return digits\n}\n\n/**\n * Strips formatting from a display ZIP, returning only digits.\n *\n * `\"12345-6789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted ZIP code\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatZIP(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── Phone ──────────────────────────────────────────────────────────────────────\n\n/**\n * Formats a raw US phone string for display.\n *\n * - Strips non-digits and a leading `1` country code (when more than 10 digits)\n * - 10 digits → `\"(201) 555-0123\"`\n * - Otherwise returns the digits-only input unchanged (partial input while typing)\n *\n * @param value - Raw or partially formatted US phone string\n * @returns Display string in `(999) 999-9999` format\n */\nexport function formatPhoneUSA(value: string): string {\n const phone = unformatPhoneUSA(value)\n if (phone.length !== 10) return phone\n return `(${phone.slice(0, 3)}) ${phone.slice(3, 6)}-${phone.slice(6)}`\n}\n\n/**\n * `\"(201) 555-0123\"` → `\"2015550123\"`\n *\n * Strips all non-digit characters. A leading country code `\"1\"` is stripped\n * only when the remainder still has at least 10 digits, so a national number\n * whose own digits start with `1` is never truncated.\n *\n * @param value - Display-formatted US phone string\n * @returns Raw digit-only string without the country code\n */\nexport function unformatPhoneUSA(value: string): string {\n const digits = value.replace(/\\D/g, '')\n if (digits.length > 10 && digits.startsWith('1')) {\n return digits.slice(1)\n }\n return digits\n}\n\n// ── SSN ──────────────────────────────────────────────────────────────────────\n\n/**\n * `\"123456789\"` → `\"123-45-6789\"`\n *\n * Truncates to at most 9 digits before formatting. Returns the digits-only\n * string unchanged when fewer than 9 digits are present.\n *\n * @param value - Raw or partially formatted SSN string\n * @returns Display string in `999-99-9999` format\n */\nexport function formatSSN(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n if (digits.length !== 9) return digits\n return `${digits.slice(0, 3)}-${digits.slice(3, 5)}-${digits.slice(5)}`\n}\n\n/**\n * `\"123-45-6789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted SSN string\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatSSN(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── EIN ──────────────────────────────────────────────────────────────────────\n\n/**\n * `\"123456789\"` → `\"12-3456789\"`\n *\n * Truncates to at most 9 digits before formatting. Returns the digits-only\n * string unchanged when fewer than 9 digits are present.\n *\n * @param value - Raw or partially formatted EIN string\n * @returns Display string in `99-9999999` format\n */\nexport function formatEIN(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n if (digits.length !== 9) return digits\n return `${digits.slice(0, 2)}-${digits.slice(2)}`\n}\n\n/**\n * `\"12-3456789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted EIN string\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatEIN(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\nregisterMask('formatZIP', formatZIP)\nregisterMask('unformatZIP', unformatZIP)\nregisterMask('formatPhoneUSA', formatPhoneUSA)\nregisterMask('unformatPhoneUSA', unformatPhoneUSA)\nregisterMask('formatSSN', formatSSN)\nregisterMask('unformatSSN', unformatSSN)\nregisterMask('formatEIN', formatEIN)\nregisterMask('unformatEIN', unformatEIN)\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCFX5EF4R_js = require('./chunk-CFX5EF4R.js');
|
|
4
|
+
|
|
5
|
+
// src/rules/validators/usa.ts
|
|
6
|
+
var PHONE_USA_REGEX = /^[2-9]\d{2}[2-9]\d{6}$/;
|
|
7
|
+
function unformatPhoneUSADigits(value) {
|
|
8
|
+
const digits = value.replace(/\D/g, "");
|
|
9
|
+
if (digits.length > 10 && digits.startsWith("1")) {
|
|
10
|
+
return digits.slice(1);
|
|
11
|
+
}
|
|
12
|
+
return digits;
|
|
13
|
+
}
|
|
14
|
+
function validateZIP(value) {
|
|
15
|
+
const trimmed = value.trim();
|
|
16
|
+
if (!/^\d{5}(-\d{4})?$/.test(trimmed)) {
|
|
17
|
+
return "country-forms.validation.postalCode.USA";
|
|
18
|
+
}
|
|
19
|
+
if (/^0+(-0+)?$/.test(trimmed)) {
|
|
20
|
+
return "country-forms.validation.postalCode.USA";
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
function validatePhoneUSA(value) {
|
|
25
|
+
const phone = unformatPhoneUSADigits(value);
|
|
26
|
+
if (!PHONE_USA_REGEX.test(phone)) {
|
|
27
|
+
return "country-forms.validation.invalid";
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function validateSSN(value) {
|
|
32
|
+
const digits = value.replace(/\D/g, "");
|
|
33
|
+
if (digits.length !== 9) return "country-forms.validation.invalid";
|
|
34
|
+
const area = digits.slice(0, 3);
|
|
35
|
+
const group = digits.slice(3, 5);
|
|
36
|
+
const serial = digits.slice(5);
|
|
37
|
+
if (area === "000" || area === "666" || Number(area) >= 900) {
|
|
38
|
+
return "country-forms.validation.invalid";
|
|
39
|
+
}
|
|
40
|
+
if (group === "00") return "country-forms.validation.invalid";
|
|
41
|
+
if (serial === "0000") return "country-forms.validation.invalid";
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function validateEIN(value) {
|
|
45
|
+
const digits = value.replace(/\D/g, "");
|
|
46
|
+
if (digits.length !== 9) return "country-forms.validation.invalid";
|
|
47
|
+
if (/^0+$/.test(digits)) return "country-forms.validation.invalid";
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
chunkCFX5EF4R_js.registerValidator("validateZIP", validateZIP);
|
|
51
|
+
chunkCFX5EF4R_js.registerValidator("validatePhoneUSA", validatePhoneUSA);
|
|
52
|
+
chunkCFX5EF4R_js.registerValidator("validateSSN", validateSSN);
|
|
53
|
+
chunkCFX5EF4R_js.registerValidator("validateEIN", validateEIN);
|
|
54
|
+
|
|
55
|
+
exports.unformatPhoneUSADigits = unformatPhoneUSADigits;
|
|
56
|
+
exports.validateEIN = validateEIN;
|
|
57
|
+
exports.validatePhoneUSA = validatePhoneUSA;
|
|
58
|
+
exports.validateSSN = validateSSN;
|
|
59
|
+
exports.validateZIP = validateZIP;
|
|
60
|
+
//# sourceMappingURL=usa-B6NCCTF6.js.map
|
|
61
|
+
//# sourceMappingURL=usa-B6NCCTF6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules/validators/usa.ts"],"names":["registerValidator"],"mappings":";;;;;AA4BA,IAAM,eAAA,GAAkB,wBAAA;AAcjB,SAAS,uBAAuB,KAAA,EAAuB;AAC5D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AACtC,EAAA,IAAI,OAAO,MAAA,GAAS,EAAA,IAAM,MAAA,CAAO,UAAA,CAAW,GAAG,CAAA,EAAG;AAChD,IAAA,OAAO,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,EACvB;AACA,EAAA,OAAO,MAAA;AACT;AAgBO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAE3B,EAAA,IAAI,CAAC,kBAAA,CAAmB,IAAA,CAAK,OAAO,CAAA,EAAG;AACrC,IAAA,OAAO,yCAAA;AAAA,EACT;AAEA,EAAA,IAAI,YAAA,CAAa,IAAA,CAAK,OAAO,CAAA,EAAG;AAC9B,IAAA,OAAO,yCAAA;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eAAe,WAAW,CAAA;AAC5CA,kCAAA,CAAkB,oBAAoB,gBAAgB,CAAA;AACtDA,kCAAA,CAAkB,eAAe,WAAW,CAAA;AAC5CA,kCAAA,CAAkB,eAAe,WAAW,CAAA","file":"usa-B6NCCTF6.js","sourcesContent":["/**\n * @module rules/validators/usa\n *\n * Synchronous validators for United States address and personal-data fields.\n * Importing this module registers all validators in the shared registry.\n *\n * Registered refs:\n * - `\"validateZIP\"` — US ZIP code format validation (5-digit and ZIP+4)\n * - `\"validatePhoneUSA\"` — US/NANP phone number (10 digits, optional `+1` country code)\n * - `\"validateSSN\"` — US Social Security Number (9 digits, well-known invalid ranges rejected)\n * - `\"validateEIN\"` — US Employer Identification Number (9 digits)\n */\n\nimport { registerValidator } from './index'\n\n/**\n * Structural NANP phone check: 10 digits where neither the area code nor the\n * central-office (exchange) code may start with 0 or 1 (`[2-9]`). Applied to the\n * digits-only string after stripping the optional `+1` country code\n * (see {@link unformatPhoneUSADigits}).\n *\n * We validate the NANP *structure* on purpose instead of an allowlist of known\n * US area codes. A hardcoded allowlist silently rejects valid numbers from\n * regions whose area codes the NANPA allocated after the list was written, with\n * no actionable error and no mechanism to flag the staleness — blocking\n * legitimate submissions in production. Structural validation accepts any future\n * allocation while still rejecting the impossible `0xx`/`1xx` ranges.\n */\nconst PHONE_USA_REGEX = /^[2-9]\\d{2}[2-9]\\d{6}$/\n\n/**\n * Strips non-digits and the optional leading `1` country code, returning the\n * 10-digit national number when possible.\n *\n * NOTE: this mirrors `unformatPhoneUSA` in `rules/masks/usa.ts` by design. The\n * duplication is intentional: validators and masks are independent modules that\n * load separately (a consumer can import one without the other, preserving\n * tree-shaking and module isolation). Validators must NOT import from masks, so\n * the small amount of shared logic is copied rather than shared. It is exported\n * so a cross-module test can assert that both copies stay in sync — keep both\n * implementations identical if the unformat rule changes.\n */\nexport function unformatPhoneUSADigits(value: string): string {\n const digits = value.replace(/\\D/g, '')\n if (digits.length > 10 && digits.startsWith('1')) {\n return digits.slice(1)\n }\n return digits\n}\n\n/**\n * Validates a US ZIP code.\n *\n * Accepts:\n * - 5-digit ZIP: `\"12345\"`\n * - ZIP+4: `\"12345-6789\"`\n *\n * Leading zeros are valid (e.g. `\"01234\"` for Massachusetts).\n * All-zeros (`\"00000\"`, `\"00000-0000\"`) is invalid.\n * Whitespace is trimmed before validation.\n *\n * @param value - ZIP code string to validate (e.g. `\"10001\"` or `\"10001-1234\"`)\n * @returns `true` when valid, or an i18n error key string when invalid\n */\nexport function validateZIP(value: string): boolean | string {\n const trimmed = value.trim()\n\n if (!/^\\d{5}(-\\d{4})?$/.test(trimmed)) {\n return 'country-forms.validation.postalCode.USA'\n }\n\n if (/^0+(-0+)?$/.test(trimmed)) {\n return 'country-forms.validation.postalCode.USA'\n }\n\n return true\n}\n\n/**\n * Validates a US phone number (North American Numbering Plan).\n *\n * Accepts masked (`\"(201) 555-0123\"`) and unmasked (`\"2015550123\"`) forms, as\n * well as numbers prefixed with the country code `+1` / `1`. Non-digit\n * characters are stripped before validation.\n *\n * Rules:\n * - After stripping the optional country code, the number must be 10 digits.\n * - NANP structure: neither the area code nor the exchange code may begin with\n * `0` or `1` (see {@link PHONE_USA_REGEX} for why this replaces an allowlist).\n *\n * @param value - Phone string to validate (with or without mask or `+1` prefix)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validatePhoneUSA(value: string): boolean | string {\n const phone = unformatPhoneUSADigits(value)\n if (!PHONE_USA_REGEX.test(phone)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n/**\n * Validates a US Social Security Number (SSN).\n *\n * Accepts masked (`\"123-45-6789\"`) and unmasked (`\"123456789\"`) forms.\n * Rules (per SSA rules for never-issued numbers):\n * - Exactly 9 digits after stripping non-digits.\n * - Area number (first 3 digits) must not be `000`, `666`, or in the `900–999` range.\n * - Group number (digits 4–5) must not be `00`.\n * - Serial number (digits 6–9) must not be `0000`.\n *\n * @param value - SSN string to validate (with or without mask)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateSSN(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 9) return 'country-forms.validation.invalid'\n\n const area = digits.slice(0, 3)\n const group = digits.slice(3, 5)\n const serial = digits.slice(5)\n\n if (area === '000' || area === '666' || Number(area) >= 900) {\n return 'country-forms.validation.invalid'\n }\n if (group === '00') return 'country-forms.validation.invalid'\n if (serial === '0000') return 'country-forms.validation.invalid'\n\n return true\n}\n\n/**\n * Validates a US Employer Identification Number (EIN).\n *\n * Accepts masked (`\"12-3456789\"`) and unmasked (`\"123456789\"`) forms.\n * Rules:\n * - Exactly 9 digits after stripping non-digits.\n * - All-zeros input is invalid.\n *\n * Limitation: this is a **structural** check only. The IRS encodes the issuing\n * campus in the first two digits, and not every `01–99` prefix is assigned, but\n * the assigned set changes over time and cannot be verified without an external\n * lookup. We intentionally do NOT validate the prefix here to avoid false\n * negatives for legitimate EINs — do not expect full IRS-level validation.\n *\n * @param value - EIN string to validate (with or without mask)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateEIN(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 9) return 'country-forms.validation.invalid'\n if (/^0+$/.test(digits)) return 'country-forms.validation.invalid'\n\n return true\n}\n\nregisterValidator('validateZIP', validateZIP)\nregisterValidator('validatePhoneUSA', validatePhoneUSA)\nregisterValidator('validateSSN', validateSSN)\nregisterValidator('validateEIN', validateEIN)\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { registerValidator } from './chunk-KWESVZKV.mjs';
|
|
2
|
+
|
|
3
|
+
// src/rules/validators/usa.ts
|
|
4
|
+
var PHONE_USA_REGEX = /^[2-9]\d{2}[2-9]\d{6}$/;
|
|
5
|
+
function unformatPhoneUSADigits(value) {
|
|
6
|
+
const digits = value.replace(/\D/g, "");
|
|
7
|
+
if (digits.length > 10 && digits.startsWith("1")) {
|
|
8
|
+
return digits.slice(1);
|
|
9
|
+
}
|
|
10
|
+
return digits;
|
|
11
|
+
}
|
|
12
|
+
function validateZIP(value) {
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
if (!/^\d{5}(-\d{4})?$/.test(trimmed)) {
|
|
15
|
+
return "country-forms.validation.postalCode.USA";
|
|
16
|
+
}
|
|
17
|
+
if (/^0+(-0+)?$/.test(trimmed)) {
|
|
18
|
+
return "country-forms.validation.postalCode.USA";
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
function validatePhoneUSA(value) {
|
|
23
|
+
const phone = unformatPhoneUSADigits(value);
|
|
24
|
+
if (!PHONE_USA_REGEX.test(phone)) {
|
|
25
|
+
return "country-forms.validation.invalid";
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function validateSSN(value) {
|
|
30
|
+
const digits = value.replace(/\D/g, "");
|
|
31
|
+
if (digits.length !== 9) return "country-forms.validation.invalid";
|
|
32
|
+
const area = digits.slice(0, 3);
|
|
33
|
+
const group = digits.slice(3, 5);
|
|
34
|
+
const serial = digits.slice(5);
|
|
35
|
+
if (area === "000" || area === "666" || Number(area) >= 900) {
|
|
36
|
+
return "country-forms.validation.invalid";
|
|
37
|
+
}
|
|
38
|
+
if (group === "00") return "country-forms.validation.invalid";
|
|
39
|
+
if (serial === "0000") return "country-forms.validation.invalid";
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
function validateEIN(value) {
|
|
43
|
+
const digits = value.replace(/\D/g, "");
|
|
44
|
+
if (digits.length !== 9) return "country-forms.validation.invalid";
|
|
45
|
+
if (/^0+$/.test(digits)) return "country-forms.validation.invalid";
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
registerValidator("validateZIP", validateZIP);
|
|
49
|
+
registerValidator("validatePhoneUSA", validatePhoneUSA);
|
|
50
|
+
registerValidator("validateSSN", validateSSN);
|
|
51
|
+
registerValidator("validateEIN", validateEIN);
|
|
52
|
+
|
|
53
|
+
export { unformatPhoneUSADigits, validateEIN, validatePhoneUSA, validateSSN, validateZIP };
|
|
54
|
+
//# sourceMappingURL=usa-LOOP7MRM.mjs.map
|
|
55
|
+
//# sourceMappingURL=usa-LOOP7MRM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules/validators/usa.ts"],"names":[],"mappings":";;;AA4BA,IAAM,eAAA,GAAkB,wBAAA;AAcjB,SAAS,uBAAuB,KAAA,EAAuB;AAC5D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AACtC,EAAA,IAAI,OAAO,MAAA,GAAS,EAAA,IAAM,MAAA,CAAO,UAAA,CAAW,GAAG,CAAA,EAAG;AAChD,IAAA,OAAO,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,EACvB;AACA,EAAA,OAAO,MAAA;AACT;AAgBO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAE3B,EAAA,IAAI,CAAC,kBAAA,CAAmB,IAAA,CAAK,OAAO,CAAA,EAAG;AACrC,IAAA,OAAO,yCAAA;AAAA,EACT;AAEA,EAAA,IAAI,YAAA,CAAa,IAAA,CAAK,OAAO,CAAA,EAAG;AAC9B,IAAA,OAAO,yCAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;AAiBO,SAAS,iBAAiB,KAAA,EAAiC;AAChE,EAAA,MAAM,KAAA,GAAQ,uBAAuB,KAAK,CAAA;AAC1C,EAAA,IAAI,CAAC,eAAA,CAAgB,IAAA,CAAK,KAAK,CAAA,EAAG;AAChC,IAAA,OAAO,kCAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAeO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAEtC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,kCAAA;AAEhC,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAC9B,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA;AAE7B,EAAA,IAAI,SAAS,KAAA,IAAS,IAAA,KAAS,SAAS,MAAA,CAAO,IAAI,KAAK,GAAA,EAAK;AAC3D,IAAA,OAAO,kCAAA;AAAA,EACT;AACA,EAAA,IAAI,KAAA,KAAU,MAAM,OAAO,kCAAA;AAC3B,EAAA,IAAI,MAAA,KAAW,QAAQ,OAAO,kCAAA;AAE9B,EAAA,OAAO,IAAA;AACT;AAmBO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAEtC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,kCAAA;AAChC,EAAA,IAAI,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,EAAG,OAAO,kCAAA;AAEhC,EAAA,OAAO,IAAA;AACT;AAEA,iBAAA,CAAkB,eAAe,WAAW,CAAA;AAC5C,iBAAA,CAAkB,oBAAoB,gBAAgB,CAAA;AACtD,iBAAA,CAAkB,eAAe,WAAW,CAAA;AAC5C,iBAAA,CAAkB,eAAe,WAAW,CAAA","file":"usa-LOOP7MRM.mjs","sourcesContent":["/**\n * @module rules/validators/usa\n *\n * Synchronous validators for United States address and personal-data fields.\n * Importing this module registers all validators in the shared registry.\n *\n * Registered refs:\n * - `\"validateZIP\"` — US ZIP code format validation (5-digit and ZIP+4)\n * - `\"validatePhoneUSA\"` — US/NANP phone number (10 digits, optional `+1` country code)\n * - `\"validateSSN\"` — US Social Security Number (9 digits, well-known invalid ranges rejected)\n * - `\"validateEIN\"` — US Employer Identification Number (9 digits)\n */\n\nimport { registerValidator } from './index'\n\n/**\n * Structural NANP phone check: 10 digits where neither the area code nor the\n * central-office (exchange) code may start with 0 or 1 (`[2-9]`). Applied to the\n * digits-only string after stripping the optional `+1` country code\n * (see {@link unformatPhoneUSADigits}).\n *\n * We validate the NANP *structure* on purpose instead of an allowlist of known\n * US area codes. A hardcoded allowlist silently rejects valid numbers from\n * regions whose area codes the NANPA allocated after the list was written, with\n * no actionable error and no mechanism to flag the staleness — blocking\n * legitimate submissions in production. Structural validation accepts any future\n * allocation while still rejecting the impossible `0xx`/`1xx` ranges.\n */\nconst PHONE_USA_REGEX = /^[2-9]\\d{2}[2-9]\\d{6}$/\n\n/**\n * Strips non-digits and the optional leading `1` country code, returning the\n * 10-digit national number when possible.\n *\n * NOTE: this mirrors `unformatPhoneUSA` in `rules/masks/usa.ts` by design. The\n * duplication is intentional: validators and masks are independent modules that\n * load separately (a consumer can import one without the other, preserving\n * tree-shaking and module isolation). Validators must NOT import from masks, so\n * the small amount of shared logic is copied rather than shared. It is exported\n * so a cross-module test can assert that both copies stay in sync — keep both\n * implementations identical if the unformat rule changes.\n */\nexport function unformatPhoneUSADigits(value: string): string {\n const digits = value.replace(/\\D/g, '')\n if (digits.length > 10 && digits.startsWith('1')) {\n return digits.slice(1)\n }\n return digits\n}\n\n/**\n * Validates a US ZIP code.\n *\n * Accepts:\n * - 5-digit ZIP: `\"12345\"`\n * - ZIP+4: `\"12345-6789\"`\n *\n * Leading zeros are valid (e.g. `\"01234\"` for Massachusetts).\n * All-zeros (`\"00000\"`, `\"00000-0000\"`) is invalid.\n * Whitespace is trimmed before validation.\n *\n * @param value - ZIP code string to validate (e.g. `\"10001\"` or `\"10001-1234\"`)\n * @returns `true` when valid, or an i18n error key string when invalid\n */\nexport function validateZIP(value: string): boolean | string {\n const trimmed = value.trim()\n\n if (!/^\\d{5}(-\\d{4})?$/.test(trimmed)) {\n return 'country-forms.validation.postalCode.USA'\n }\n\n if (/^0+(-0+)?$/.test(trimmed)) {\n return 'country-forms.validation.postalCode.USA'\n }\n\n return true\n}\n\n/**\n * Validates a US phone number (North American Numbering Plan).\n *\n * Accepts masked (`\"(201) 555-0123\"`) and unmasked (`\"2015550123\"`) forms, as\n * well as numbers prefixed with the country code `+1` / `1`. Non-digit\n * characters are stripped before validation.\n *\n * Rules:\n * - After stripping the optional country code, the number must be 10 digits.\n * - NANP structure: neither the area code nor the exchange code may begin with\n * `0` or `1` (see {@link PHONE_USA_REGEX} for why this replaces an allowlist).\n *\n * @param value - Phone string to validate (with or without mask or `+1` prefix)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validatePhoneUSA(value: string): boolean | string {\n const phone = unformatPhoneUSADigits(value)\n if (!PHONE_USA_REGEX.test(phone)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n/**\n * Validates a US Social Security Number (SSN).\n *\n * Accepts masked (`\"123-45-6789\"`) and unmasked (`\"123456789\"`) forms.\n * Rules (per SSA rules for never-issued numbers):\n * - Exactly 9 digits after stripping non-digits.\n * - Area number (first 3 digits) must not be `000`, `666`, or in the `900–999` range.\n * - Group number (digits 4–5) must not be `00`.\n * - Serial number (digits 6–9) must not be `0000`.\n *\n * @param value - SSN string to validate (with or without mask)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateSSN(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 9) return 'country-forms.validation.invalid'\n\n const area = digits.slice(0, 3)\n const group = digits.slice(3, 5)\n const serial = digits.slice(5)\n\n if (area === '000' || area === '666' || Number(area) >= 900) {\n return 'country-forms.validation.invalid'\n }\n if (group === '00') return 'country-forms.validation.invalid'\n if (serial === '0000') return 'country-forms.validation.invalid'\n\n return true\n}\n\n/**\n * Validates a US Employer Identification Number (EIN).\n *\n * Accepts masked (`\"12-3456789\"`) and unmasked (`\"123456789\"`) forms.\n * Rules:\n * - Exactly 9 digits after stripping non-digits.\n * - All-zeros input is invalid.\n *\n * Limitation: this is a **structural** check only. The IRS encodes the issuing\n * campus in the first two digits, and not every `01–99` prefix is assigned, but\n * the assigned set changes over time and cannot be verified without an external\n * lookup. We intentionally do NOT validate the prefix here to avoid false\n * negatives for legitimate EINs — do not expect full IRS-level validation.\n *\n * @param value - EIN string to validate (with or without mask)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateEIN(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 9) return 'country-forms.validation.invalid'\n if (/^0+$/.test(digits)) return 'country-forms.validation.invalid'\n\n return true\n}\n\nregisterValidator('validateZIP', validateZIP)\nregisterValidator('validatePhoneUSA', validatePhoneUSA)\nregisterValidator('validateSSN', validateSSN)\nregisterValidator('validateEIN', validateEIN)\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkBQPGLWMB_js = require('./chunk-BQPGLWMB.js');
|
|
4
|
+
|
|
5
|
+
// src/rules/masks/usa.ts
|
|
6
|
+
function formatZIP(value) {
|
|
7
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
8
|
+
if (digits.length === 5) return digits;
|
|
9
|
+
if (digits.length === 9) return `${digits.slice(0, 5)}-${digits.slice(5)}`;
|
|
10
|
+
return digits;
|
|
11
|
+
}
|
|
12
|
+
function unformatZIP(value) {
|
|
13
|
+
return value.replace(/\D/g, "");
|
|
14
|
+
}
|
|
15
|
+
function formatPhoneUSA(value) {
|
|
16
|
+
const phone = unformatPhoneUSA(value);
|
|
17
|
+
if (phone.length !== 10) return phone;
|
|
18
|
+
return `(${phone.slice(0, 3)}) ${phone.slice(3, 6)}-${phone.slice(6)}`;
|
|
19
|
+
}
|
|
20
|
+
function unformatPhoneUSA(value) {
|
|
21
|
+
const digits = value.replace(/\D/g, "");
|
|
22
|
+
if (digits.length > 10 && digits.startsWith("1")) {
|
|
23
|
+
return digits.slice(1);
|
|
24
|
+
}
|
|
25
|
+
return digits;
|
|
26
|
+
}
|
|
27
|
+
function formatSSN(value) {
|
|
28
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
29
|
+
if (digits.length !== 9) return digits;
|
|
30
|
+
return `${digits.slice(0, 3)}-${digits.slice(3, 5)}-${digits.slice(5)}`;
|
|
31
|
+
}
|
|
32
|
+
function unformatSSN(value) {
|
|
33
|
+
return value.replace(/\D/g, "");
|
|
34
|
+
}
|
|
35
|
+
function formatEIN(value) {
|
|
36
|
+
const digits = value.replace(/\D/g, "").slice(0, 9);
|
|
37
|
+
if (digits.length !== 9) return digits;
|
|
38
|
+
return `${digits.slice(0, 2)}-${digits.slice(2)}`;
|
|
39
|
+
}
|
|
40
|
+
function unformatEIN(value) {
|
|
41
|
+
return value.replace(/\D/g, "");
|
|
42
|
+
}
|
|
43
|
+
chunkBQPGLWMB_js.registerMask("formatZIP", formatZIP);
|
|
44
|
+
chunkBQPGLWMB_js.registerMask("unformatZIP", unformatZIP);
|
|
45
|
+
chunkBQPGLWMB_js.registerMask("formatPhoneUSA", formatPhoneUSA);
|
|
46
|
+
chunkBQPGLWMB_js.registerMask("unformatPhoneUSA", unformatPhoneUSA);
|
|
47
|
+
chunkBQPGLWMB_js.registerMask("formatSSN", formatSSN);
|
|
48
|
+
chunkBQPGLWMB_js.registerMask("unformatSSN", unformatSSN);
|
|
49
|
+
chunkBQPGLWMB_js.registerMask("formatEIN", formatEIN);
|
|
50
|
+
chunkBQPGLWMB_js.registerMask("unformatEIN", unformatEIN);
|
|
51
|
+
|
|
52
|
+
exports.formatEIN = formatEIN;
|
|
53
|
+
exports.formatPhoneUSA = formatPhoneUSA;
|
|
54
|
+
exports.formatSSN = formatSSN;
|
|
55
|
+
exports.formatZIP = formatZIP;
|
|
56
|
+
exports.unformatEIN = unformatEIN;
|
|
57
|
+
exports.unformatPhoneUSA = unformatPhoneUSA;
|
|
58
|
+
exports.unformatSSN = unformatSSN;
|
|
59
|
+
exports.unformatZIP = unformatZIP;
|
|
60
|
+
//# sourceMappingURL=usa-OQ44AFEI.js.map
|
|
61
|
+
//# sourceMappingURL=usa-OQ44AFEI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules/masks/usa.ts"],"names":["registerMask"],"mappings":";;;;;AA0BO,SAAS,UAAU,KAAA,EAAuB;AAC/C,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CAAE,KAAA,CAAM,GAAG,CAAC,CAAA;AAElD,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAChC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,GAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAExE,EAAA,OAAO,MAAA;AACT;AAUO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChC;AAcO,SAAS,eAAe,KAAA,EAAuB;AACpD,EAAA,MAAM,KAAA,GAAQ,iBAAiB,KAAK,CAAA;AACpC,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,EAAA,EAAI,OAAO,KAAA;AAChC,EAAA,OAAO,IAAI,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,KAAA,CAAM,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACtE;AAYO,SAAS,iBAAiB,KAAA,EAAuB;AACtD,EAAA,MA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EAA,6BAAA,CAAa,aAAa,SAAS,CAAA;AACnCA,6BAAA,CAAa,eAAe,WAAW,CAAA;AACvCA,6BAAA,CAAa,kBAAkB,cAAc,CAAA;AAC7CA,6BAAA,CAAa,oBAAoB,gBAAgB,CAAA;AACjDA,6BAAA,CAAa,aAAa,SAAS,CAAA;AACnCA,6BAAA,CAAa,eAAe,WAAW,CAAA;AACvCA,6BAAA,CAAa,aAAa,SAAS,CAAA;AACnCA,6BAAA,CAAa,eAAe,WAAW,CAAA","file":"usa-OQ44AFEI.js","sourcesContent":["/**\n * @module rules/masks/usa\n *\n * Format/unformat functions for United States address and personal-data fields.\n * Importing this module registers all masks in the shared registry.\n *\n * Registered refs:\n * - `\"formatZIP\"` / `\"unformatZIP\"` — ZIP+4 display formatting (99999-9999)\n * - `\"formatPhoneUSA\"` / `\"unformatPhoneUSA\"` — US phone ((999) 999-9999)\n * - `\"formatSSN\"` / `\"unformatSSN\"` — Social Security Number (999-99-9999)\n * - `\"formatEIN\"` / `\"unformatEIN\"` — Employer Identification Number (99-9999999)\n */\n\nimport { registerMask } from './index'\n\n/**\n * Formats a raw ZIP code string for display.\n *\n * - Strips non-digit characters and truncates to at most 9 digits\n * - 5 digits → `\"12345\"` (unchanged)\n * - 9 digits → `\"12345-6789\"` (hyphen inserted)\n * - Otherwise returns the digits-only input unchanged\n *\n * @param value - Raw or partially formatted ZIP code\n * @returns Display string with hyphen for ZIP+4, or digits-only for 5-digit ZIP\n */\nexport function formatZIP(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n\n if (digits.length === 5) return digits\n if (digits.length === 9) return `${digits.slice(0, 5)}-${digits.slice(5)}`\n\n return digits\n}\n\n/**\n * Strips formatting from a display ZIP, returning only digits.\n *\n * `\"12345-6789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted ZIP code\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatZIP(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── Phone ──────────────────────────────────────────────────────────────────────\n\n/**\n * Formats a raw US phone string for display.\n *\n * - Strips non-digits and a leading `1` country code (when more than 10 digits)\n * - 10 digits → `\"(201) 555-0123\"`\n * - Otherwise returns the digits-only input unchanged (partial input while typing)\n *\n * @param value - Raw or partially formatted US phone string\n * @returns Display string in `(999) 999-9999` format\n */\nexport function formatPhoneUSA(value: string): string {\n const phone = unformatPhoneUSA(value)\n if (phone.length !== 10) return phone\n return `(${phone.slice(0, 3)}) ${phone.slice(3, 6)}-${phone.slice(6)}`\n}\n\n/**\n * `\"(201) 555-0123\"` → `\"2015550123\"`\n *\n * Strips all non-digit characters. A leading country code `\"1\"` is stripped\n * only when the remainder still has at least 10 digits, so a national number\n * whose own digits start with `1` is never truncated.\n *\n * @param value - Display-formatted US phone string\n * @returns Raw digit-only string without the country code\n */\nexport function unformatPhoneUSA(value: string): string {\n const digits = value.replace(/\\D/g, '')\n if (digits.length > 10 && digits.startsWith('1')) {\n return digits.slice(1)\n }\n return digits\n}\n\n// ── SSN ──────────────────────────────────────────────────────────────────────\n\n/**\n * `\"123456789\"` → `\"123-45-6789\"`\n *\n * Truncates to at most 9 digits before formatting. Returns the digits-only\n * string unchanged when fewer than 9 digits are present.\n *\n * @param value - Raw or partially formatted SSN string\n * @returns Display string in `999-99-9999` format\n */\nexport function formatSSN(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n if (digits.length !== 9) return digits\n return `${digits.slice(0, 3)}-${digits.slice(3, 5)}-${digits.slice(5)}`\n}\n\n/**\n * `\"123-45-6789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted SSN string\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatSSN(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── EIN ──────────────────────────────────────────────────────────────────────\n\n/**\n * `\"123456789\"` → `\"12-3456789\"`\n *\n * Truncates to at most 9 digits before formatting. Returns the digits-only\n * string unchanged when fewer than 9 digits are present.\n *\n * @param value - Raw or partially formatted EIN string\n * @returns Display string in `99-9999999` format\n */\nexport function formatEIN(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 9)\n if (digits.length !== 9) return digits\n return `${digits.slice(0, 2)}-${digits.slice(2)}`\n}\n\n/**\n * `\"12-3456789\"` → `\"123456789\"`\n *\n * @param value - Display-formatted EIN string\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatEIN(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\nregisterMask('formatZIP', formatZIP)\nregisterMask('unformatZIP', unformatZIP)\nregisterMask('formatPhoneUSA', formatPhoneUSA)\nregisterMask('unformatPhoneUSA', unformatPhoneUSA)\nregisterMask('formatSSN', formatSSN)\nregisterMask('unformatSSN', unformatSSN)\nregisterMask('formatEIN', formatEIN)\nregisterMask('unformatEIN', unformatEIN)\n"]}
|
package/package.json
CHANGED
package/dist/BRA-PMVV6KOM.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/personal-data/BRA.ts"],"names":[],"mappings":";;;AA0BA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,mBAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QAAA,EAAU,eAAA;AAAA,EACV,MAAA,EAAQ;AAAA,IACN;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,aAAA;AAAA,MACN,KAAA,EAAO,8CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,QACP,EAAE,KAAA,EAAO,YAAA,EAAc,YAAA,EAAc,mDAAA,EAAoD;AAAA,QACzF,EAAE,KAAA,EAAO,UAAA,EAAY,YAAA,EAAc,iDAAA;AAAkD;AACvF,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,WAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,6CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX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A,MACE,IAAA,EAAM,KAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,uCAAA;AAAA,MACP,WAAA,EAAa,6CAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,WAAA,EAAa,8CAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAa,cAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-PMVV6KOM.js","sourcesContent":["/**\n * Personal-data schema for Brazil (BRA).\n *\n * Field order: personType → firstName → lastName → email → phone → cpf → cnpj\n *\n * `personType` drives conditional visibility:\n * - `\"individual\"` → `lastName`, `cpf` visible; `cnpj` hidden\n * - `\"business\"` → `cnpj` visible; `lastName`, `cpf` hidden\n *\n * `firstName` uses `conditionalLabel` keyed by `personType`:\n * - `\"individual\"` → \"First name\" / \"Nome\"\n * - `\"business\"` → \"Company name\" / \"Razão social\"\n *\n * `lastName` is only visible for individuals (hidden for businesses).\n *\n * Email: `joao.silva@example.com` -> validated by `validateEmail`.\n * Phone: `(11) 98888-7777` -> validated by `validatePhoneBRA`, masked by `formatPhoneBRA`/`unformatPhoneBRA`.\n * CPF: `999.999.999-99` — validated by `validateCPF`, masked by `formatCPF`/`unformatCPF`.\n * CNPJ: `99.999.999/9999-99` (numeric, legacy) or `AA.AAA.AAA/AAAA-99` (alphanumeric, SERPRO 2024+) —\n * validated by `validateCNPJ`, masked by `formatCNPJ`/`unformatCNPJ`. The first 12 characters can be\n * `[A-Z0-9]`; the last 2 (check digits) are always numeric.\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'personal-data-BRA',\n country: 'BRA',\n formType: 'personal-data',\n fields: [\n {\n name: 'personType',\n type: 'radio-group',\n label: 'country-forms.personal-data.personType.label',\n required: true,\n options: [\n { value: 'individual', displayValue: 'country-forms.personal-data.personType.individual' },\n { value: 'business', displayValue: 'country-forms.personal-data.personType.business' },\n ],\n },\n {\n name: 'firstName',\n type: 'text',\n label: 'country-forms.personal-data.firstName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n dependsOn: 'personType',\n conditionalLabel: {\n individual: 'country-forms.personal-data.firstName.label.individual',\n business: 'country-forms.personal-data.firstName.label.business',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'lastName',\n type: 'text',\n label: 'country-forms.personal-data.lastName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'email',\n type: 'email',\n label: 'country-forms.personal-data.email.label',\n required: true,\n inputMode: 'email',\n validation: {\n customValidator: 'validateEmail',\n },\n },\n {\n name: 'phone',\n type: 'text',\n label: 'country-forms.personal-data.phone.label',\n placeholder: 'country-forms.personal-data.phone.placeholder.BRA',\n required: true,\n maxLength: 20,\n inputMode: 'tel',\n formatRef: 'formatPhoneBRA',\n unformatRef: 'unformatPhoneBRA',\n validation: {\n customValidator: 'validatePhoneBRA',\n },\n },\n {\n name: 'cpf',\n type: 'text',\n label: 'country-forms.personal-data.cpf.label',\n placeholder: 'country-forms.personal-data.cpf.placeholder',\n required: true,\n inputMode: 'numeric',\n maxLength: 14,\n formatRef: 'formatCPF',\n unformatRef: 'unformatCPF',\n validation: {\n customValidator: 'validateCPF',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n },\n {\n name: 'cnpj',\n type: 'text',\n label: 'country-forms.personal-data.cnpj.label',\n placeholder: 'country-forms.personal-data.cnpj.placeholder',\n required: true,\n inputMode: 'text',\n maxLength: 18,\n formatRef: 'formatCNPJ',\n unformatRef: 'unformatCNPJ',\n validation: {\n customValidator: 'validateCNPJ',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'business',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/personal-data/BRA.ts"],"names":[],"mappings":";AA0BA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,mBAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QAAA,EAAU,eAAA;AAAA,EACV,MAAA,EAAQ;AAAA,IACN;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,aAAA;AAAA,MACN,KAAA,EAAO,8CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,QACP,EAAE,KAAA,EAAO,YAAA,EAAc,YAAA,EAAc,mDAAA,EAAoD;AAAA,QACzF,EAAE,KAAA,EAAO,UAAA,EAAY,YAAA,EAAc,iDAAA;AAAkD;AACvF,KACF;AAAA,I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X,SAAA,EAAW,KAAA;AAAA,MACX,SAAA,EAAW,gBAAA;AAAA,MACX,WAAA,EAAa,kBAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,KAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,uCAAA;AAAA,MACP,WAAA,EAAa,6CAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,WAAA,EAAa,8CAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAa,cAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-ZBZXE5II.mjs","sourcesContent":["/**\n * Personal-data schema for Brazil (BRA).\n *\n * Field order: personType → firstName → lastName → email → phone → cpf → cnpj\n *\n * `personType` drives conditional visibility:\n * - `\"individual\"` → `lastName`, `cpf` visible; `cnpj` hidden\n * - `\"business\"` → `cnpj` visible; `lastName`, `cpf` hidden\n *\n * `firstName` uses `conditionalLabel` keyed by `personType`:\n * - `\"individual\"` → \"First name\" / \"Nome\"\n * - `\"business\"` → \"Company name\" / \"Razão social\"\n *\n * `lastName` is only visible for individuals (hidden for businesses).\n *\n * Email: `joao.silva@example.com` -> validated by `validateEmail`.\n * Phone: `(11) 98888-7777` -> validated by `validatePhoneBRA`, masked by `formatPhoneBRA`/`unformatPhoneBRA`.\n * CPF: `999.999.999-99` — validated by `validateCPF`, masked by `formatCPF`/`unformatCPF`.\n * CNPJ: `99.999.999/9999-99` (numeric, legacy) or `AA.AAA.AAA/AAAA-99` (alphanumeric, SERPRO 2024+) —\n * validated by `validateCNPJ`, masked by `formatCNPJ`/`unformatCNPJ`. The first 12 characters can be\n * `[A-Z0-9]`; the last 2 (check digits) are always numeric.\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'personal-data-BRA',\n country: 'BRA',\n formType: 'personal-data',\n fields: [\n {\n name: 'personType',\n type: 'radio-group',\n label: 'country-forms.personal-data.personType.label',\n required: true,\n options: [\n { value: 'individual', displayValue: 'country-forms.personal-data.personType.individual' },\n { value: 'business', displayValue: 'country-forms.personal-data.personType.business' },\n ],\n },\n {\n name: 'firstName',\n type: 'text',\n label: 'country-forms.personal-data.firstName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n dependsOn: 'personType',\n conditionalLabel: {\n individual: 'country-forms.personal-data.firstName.label.individual',\n business: 'country-forms.personal-data.firstName.label.business',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'lastName',\n type: 'text',\n label: 'country-forms.personal-data.lastName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'email',\n type: 'email',\n label: 'country-forms.personal-data.email.label',\n required: true,\n inputMode: 'email',\n validation: {\n customValidator: 'validateEmail',\n },\n },\n {\n name: 'phone',\n type: 'text',\n label: 'country-forms.personal-data.phone.label',\n placeholder: 'country-forms.personal-data.phone.placeholder.BRA',\n required: true,\n maxLength: 20,\n inputMode: 'tel',\n formatRef: 'formatPhoneBRA',\n unformatRef: 'unformatPhoneBRA',\n validation: {\n customValidator: 'validatePhoneBRA',\n },\n },\n {\n name: 'cpf',\n type: 'text',\n label: 'country-forms.personal-data.cpf.label',\n placeholder: 'country-forms.personal-data.cpf.placeholder',\n required: true,\n inputMode: 'numeric',\n maxLength: 14,\n formatRef: 'formatCPF',\n unformatRef: 'unformatCPF',\n validation: {\n customValidator: 'validateCPF',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n },\n {\n name: 'cnpj',\n type: 'text',\n label: 'country-forms.personal-data.cnpj.label',\n placeholder: 'country-forms.personal-data.cnpj.placeholder',\n required: true,\n inputMode: 'text',\n maxLength: 18,\n formatRef: 'formatCNPJ',\n unformatRef: 'unformatCNPJ',\n validation: {\n customValidator: 'validateCNPJ',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'business',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rules/validators/bra.ts"],"names":[],"mappings":";;;AA6BO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAGtC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,yCAAA;AAEhC,EAAA,IAAI,IAAI,GAAA,CAAI,MAAM,CAAA,CAAE,IAAA,KAAS,GAAG,OAAO,yCAAA;AAEvC,EAAA,OA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BAAA,CAAkB,iBAAiB,aAAa,CAAA;AAChD,iBAAA,CAAkB,oBAAoB,gBAAgB,CAAA;AACtD,iBAAA,CAAkB,eAAe,WAAW,CAAA;AAC5C,iBAAA,CAAkB,gBAAgB,YAAY,CAAA","file":"bra-ILOTR4AN.mjs","sourcesContent":["/**\n * @module rules/validators/bra\n *\n * Synchronous validators for Brazilian address and personal-data fields.\n * Importing this module registers all validators in the shared registry.\n *\n * Registered refs:\n * - `\"validateCEP\"` — Brazilian postal code format\n * - `\"validateEmail\"` — Email address format (RFC 5322-inspired)\n * - `\"validatePhoneBRA\"` — Brazilian landline and mobile phone numbers\n * - `\"validateCPF\"` — Brazilian individual taxpayer ID (CPF) with check digits\n * - `\"validateCNPJ\"` — Brazilian company taxpayer ID (CNPJ), numeric or alphanumeric (SERPRO 2024+)\n */\n\nimport { registerValidator } from './index'\n\n// ── CEP ───────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian CEP (Código de Endereçamento Postal).\n *\n * Accepts both masked (\"01310-100\") and unmasked (\"01310100\") forms.\n * Rules:\n * - Must contain exactly 8 digits after stripping non-digits.\n * - All identical digits are invalid (e.g. `\"00000000\"`, `\"11111111\"`).\n *\n * @param value - The CEP string to validate (with or without mask)\n * @returns `true` if valid, or an i18n error key string when invalid\n */\nexport function validateCEP(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n // Must contain exactly 8 digits\n if (digits.length !== 8) return 'country-forms.validation.postalCode.BRA'\n // Must not be all the same digit\n if (new Set(digits).size === 1) return 'country-forms.validation.postalCode.BRA'\n\n return true\n}\n\n// ── Email ─────────────────────────────────────────────────────────────────────\n\n/**\n * Validates an email address using an RFC-inspired regex.\n *\n * Rules:\n * - Must not be empty (after trimming whitespace).\n * - Must match `local@domain.tld` with at least one dot in the domain part.\n * - This is a practical check, not a full RFC 5322 parser.\n *\n * @param value - Email string to validate\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateEmail(value: string): boolean | string {\n const email = value.trim()\n if (!email) {\n return 'country-forms.validation.invalid'\n }\n // Local part + domain labels (at least one dot before TLD). Not full RFC 5322.\n const emailRegex =\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)+$/\n if (!emailRegex.test(email)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n// ── Phone ──────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian phone number.\n *\n * Accepts masked (`\"(11) 99999-9999\"`) and unmasked (`\"11999999999\"`) forms,\n * as well as numbers prefixed with the country code `+55` or trunk prefix `0`.\n * Non-digit characters are stripped before validation.\n *\n * Rules:\n * - Area code (DDD) must be a valid 2-digit Brazilian DDD (11-99, with gaps).\n * - Mobile numbers: 9 + 8 digits (total 11 digits after DDD).\n * - Landline numbers: [1-8] + 7 digits (total 10 digits after DDD).\n *\n * @param value - Phone string to validate (with or without mask, country code, or trunk prefix)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validatePhoneBRA(value: string): boolean | string {\n const phoneRegex = /^(?:(?:(?:\\+|)55)|)(?:0|)(?:11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|36|37|38|41|42|43|44|45|46|47|48|49|51|52|53|54|55|61|62|63|64|65|66|67|68|69|71|72|73|74|75|77|78|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)(?:9\\d{8}|[1-8]\\d{7})$/\n const phone = value.replace(/\\D/g, '')\n if (!phoneRegex.test(phone)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n// ── CPF ───────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian CPF (Cadastro de Pessoas Físicas).\n *\n * Accepts masked (`\"123.456.789-09\"`) and unmasked (`\"12345678909\"`) forms.\n * Rules:\n * - Must contain exactly 11 digits after stripping non-digits.\n * - All identical digits are invalid (e.g. `\"000.000.000-00\"`).\n * - Check digits (positions 10 and 11) must satisfy the Receita Federal algorithm.\n *\n * @param value - CPF string to validate (with or without mask)\n * @returns `true` when valid, or an i18n error key string when invalid\n * @see https://www.macoratti.net/alg_cpf.htm\n */\nexport function validateCPF(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 11) return 'country-forms.validation.invalid'\n if (new Set(digits).size === 1) return 'country-forms.validation.invalid'\n\n let sum = 0\n for (let i = 0; i < 9; i++) {\n sum += Number(digits[i]) * (10 - i)\n }\n let remainder = (sum * 10) % 11\n if (remainder === 10) remainder = 0\n if (remainder !== Number(digits[9])) return 'country-forms.validation.invalid'\n\n sum = 0\n for (let i = 0; i < 10; i++) {\n sum += Number(digits[i]) * (11 - i)\n }\n remainder = (sum * 10) % 11\n if (remainder === 10) remainder = 0\n if (remainder !== Number(digits[10])) return 'country-forms.validation.invalid'\n\n return true\n}\n\n// ── CNPJ ──────────────────────────────────────────────────────────────────────\n\nconst CNPJ_TOTAL_LENGTH = 14\nconst CNPJ_BASE_LENGTH = 12\nconst CNPJ_MODULUS = 11\nconst CNPJ_BASE_CHAR_CODE = '0'.charCodeAt(0)\n\n// Shared 13-element weight table. The first check digit uses the last 12 weights\n// (over the 12-character base); the second check digit uses all 13 weights\n// (over base + first check digit). This mirrors the SERPRO reference algorithm.\nconst CNPJ_WEIGHTS = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] as const\n\nconst CNPJ_CLEAN_REGEX = /[./\\-\\s]/g\nconst CNPJ_FORMAT_REGEX = /^[A-Z0-9]{12}[0-9]{2}$/\nconst CNPJ_ALL_ZEROS_REGEX = /^0+$/\n\n/**\n * Computes a CNPJ check digit for the given alphanumeric prefix using the\n * SERPRO algorithm. Each character contributes `charCode - '0'` to the\n * weighted sum: digits `0-9` map to `0-9`, letters `A-Z` map to `17-42`.\n *\n * @internal\n */\nfunction calculateCnpjCheckDigit(prefix: string): number {\n const offset = CNPJ_WEIGHTS.length - prefix.length\n let sum = 0\n for (let i = 0; i < prefix.length; i++) {\n const charValue = prefix.charCodeAt(i) - CNPJ_BASE_CHAR_CODE\n sum += charValue * (CNPJ_WEIGHTS[offset + i] as number)\n }\n const remainder = sum % CNPJ_MODULUS\n return remainder < 2 ? 0 : CNPJ_MODULUS - remainder\n}\n\n/**\n * Validates a Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica).\n *\n * Supports both the legacy numeric format and the new alphanumeric format\n * announced by the Receita Federal (Instrução Normativa RFB 2.229/2024,\n * effective for new registrations from July 2026 onward). Numeric CNPJs\n * already issued remain valid — they are a strict subset of the new format.\n *\n * Accepted inputs:\n * - Masked numeric: `\"11.222.333/0001-81\"`\n * - Unmasked numeric: `\"11222333000181\"`\n * - Masked alphanumeric: `\"12.ABC.345/01DE-35\"`\n * - Unmasked alphanumeric: `\"12ABC34501DE35\"`\n *\n * Lowercase letters are accepted and normalized to uppercase.\n *\n * Rules:\n * - After stripping separators (`.`, `/`, `-`, whitespace), the string must be\n * exactly 14 characters long.\n * - The first 12 characters (base) must be alphanumeric uppercase (`A-Z`, `0-9`).\n * - The last 2 characters (check digits) must be numeric (`0-9`).\n * - All-zeros input is invalid (e.g. `\"00000000000000\"`).\n * - Check digits must satisfy the SERPRO algorithm: each character contributes\n * `charCode - '0'.charCode` to a weighted sum modulo 11.\n *\n * @param value - CNPJ string to validate (with or without mask, numeric or alphanumeric)\n * @returns `true` when valid, or an i18n error key string when invalid\n * @see https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico\n */\nexport function validateCNPJ(value: string): boolean | string {\n if (!value || !value.trim()) return 'country-forms.validation.invalid'\n\n const cleaned = value.trim().toUpperCase().replace(CNPJ_CLEAN_REGEX, '')\n\n if (cleaned.length !== CNPJ_TOTAL_LENGTH) return 'country-forms.validation.invalid'\n if (!CNPJ_FORMAT_REGEX.test(cleaned)) return 'country-forms.validation.invalid'\n if (CNPJ_ALL_ZEROS_REGEX.test(cleaned)) return 'country-forms.validation.invalid'\n\n const base = cleaned.slice(0, CNPJ_BASE_LENGTH)\n const providedCheck1 = Number(cleaned[CNPJ_BASE_LENGTH])\n const providedCheck2 = Number(cleaned[CNPJ_BASE_LENGTH + 1])\n\n const expectedCheck1 = calculateCnpjCheckDigit(base)\n if (providedCheck1 !== expectedCheck1) return 'country-forms.validation.invalid'\n\n const expectedCheck2 = calculateCnpjCheckDigit(base + expectedCheck1)\n if (providedCheck2 !== expectedCheck2) return 'country-forms.validation.invalid'\n\n return true\n}\n\nregisterValidator('validateCEP', validateCEP)\nregisterValidator('validateEmail', validateEmail)\nregisterValidator('validatePhoneBRA', validatePhoneBRA)\nregisterValidator('validateCPF', validateCPF)\nregisterValidator('validateCNPJ', validateCNPJ)\n"]}
|
package/dist/bra-MHTXSNLA.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rules/validators/bra.ts"],"names":["registerValidator"],"mappings":";;;;;AA6BO,SAAS,YAAY,KAAA,EAAiC;AAC3D,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAGtC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,yCAAA;AAEhC,EAAA,IAAI,IAAI,GAAA,CAAI,MAAM,CAAA,CAAE,IAAA,KAAS,GAAG,OAAO,yCAAA;AAEvC,EAAA,OAAO,IAAA;AACT;AAeO,SAAS,cAAc,KAAA,EAAiC;AAC7D,EAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,EAAK;AACzB,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,OAAO,kCAAA;AAAA,EACT;AAEA,EAAA,MAAM,UAAA,GACJ,4HAAA;AACF,EAAA,IAAI,CAAC,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG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AC5D,EAAA,IAAI,CAAC,KAAA,IAAS,CAAC,KAAA,CAAM,IAAA,IAAQ,OAAO,kCAAA;AAEpC,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK,CAAE,aAAY,CAAE,OAAA,CAAQ,kBAAkB,EAAE,CAAA;AAEvE,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,iBAAA,EAAmB,OAAO,kCAAA;AACjD,EAAA,IAAI,CAAC,iBAAA,CAAkB,IAAA,CAAK,OAAO,GAAG,OAAO,kCAAA;AAC7C,EAAA,IAAI,oBAAA,CAAqB,IAAA,CAAK,OAAO,CAAA,EAAG,OAAO,kCAAA;AAE/C,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,KAAA,CAAM,CAAA,EAAG,gBAAgB,CAAA;AAC9C,EAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAC,CAAA;AACvD,EAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,OAAA,CAAQ,gBAAA,GAAmB,CAAC,CAAC,CAAA;AAE3D,EAAA,MAAM,cAAA,GAAiB,wBAAwB,IAAI,CAAA;AACnD,EAAA,IAAI,cAAA,KAAmB,gBAAgB,OAAO,kCAAA;AAE9C,EAAA,MAAM,cAAA,GAAiB,uBAAA,CAAwB,IAAA,GAAO,cAAc,CAAA;AACpE,EAAA,IAAI,cAAA,KAAmB,gBAAgB,OAAO,kCAAA;AAE9C,EAAA,OAAO,IAAA;AACT;AAEAA,kCAAA,CAAkB,eAAe,WAAW,CAAA;AAC5CA,kCAAA,CAAkB,iBAAiB,aAAa,CAAA;AAChDA,kCAAA,CAAkB,oBAAoB,gBAAgB,CAAA;AACtDA,kCAAA,CAAkB,eAAe,WAAW,CAAA;AAC5CA,kCAAA,CAAkB,gBAAgB,YAAY,CAAA","file":"bra-MHTXSNLA.js","sourcesContent":["/**\n * @module rules/validators/bra\n *\n * Synchronous validators for Brazilian address and personal-data fields.\n * Importing this module registers all validators in the shared registry.\n *\n * Registered refs:\n * - `\"validateCEP\"` — Brazilian postal code format\n * - `\"validateEmail\"` — Email address format (RFC 5322-inspired)\n * - `\"validatePhoneBRA\"` — Brazilian landline and mobile phone numbers\n * - `\"validateCPF\"` — Brazilian individual taxpayer ID (CPF) with check digits\n * - `\"validateCNPJ\"` — Brazilian company taxpayer ID (CNPJ), numeric or alphanumeric (SERPRO 2024+)\n */\n\nimport { registerValidator } from './index'\n\n// ── CEP ───────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian CEP (Código de Endereçamento Postal).\n *\n * Accepts both masked (\"01310-100\") and unmasked (\"01310100\") forms.\n * Rules:\n * - Must contain exactly 8 digits after stripping non-digits.\n * - All identical digits are invalid (e.g. `\"00000000\"`, `\"11111111\"`).\n *\n * @param value - The CEP string to validate (with or without mask)\n * @returns `true` if valid, or an i18n error key string when invalid\n */\nexport function validateCEP(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n // Must contain exactly 8 digits\n if (digits.length !== 8) return 'country-forms.validation.postalCode.BRA'\n // Must not be all the same digit\n if (new Set(digits).size === 1) return 'country-forms.validation.postalCode.BRA'\n\n return true\n}\n\n// ── Email ─────────────────────────────────────────────────────────────────────\n\n/**\n * Validates an email address using an RFC-inspired regex.\n *\n * Rules:\n * - Must not be empty (after trimming whitespace).\n * - Must match `local@domain.tld` with at least one dot in the domain part.\n * - This is a practical check, not a full RFC 5322 parser.\n *\n * @param value - Email string to validate\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validateEmail(value: string): boolean | string {\n const email = value.trim()\n if (!email) {\n return 'country-forms.validation.invalid'\n }\n // Local part + domain labels (at least one dot before TLD). Not full RFC 5322.\n const emailRegex =\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)+$/\n if (!emailRegex.test(email)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n// ── Phone ──────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian phone number.\n *\n * Accepts masked (`\"(11) 99999-9999\"`) and unmasked (`\"11999999999\"`) forms,\n * as well as numbers prefixed with the country code `+55` or trunk prefix `0`.\n * Non-digit characters are stripped before validation.\n *\n * Rules:\n * - Area code (DDD) must be a valid 2-digit Brazilian DDD (11-99, with gaps).\n * - Mobile numbers: 9 + 8 digits (total 11 digits after DDD).\n * - Landline numbers: [1-8] + 7 digits (total 10 digits after DDD).\n *\n * @param value - Phone string to validate (with or without mask, country code, or trunk prefix)\n * @returns `true` when valid, or the i18n error key `\"country-forms.validation.invalid\"` when invalid\n */\nexport function validatePhoneBRA(value: string): boolean | string {\n const phoneRegex = /^(?:(?:(?:\\+|)55)|)(?:0|)(?:11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|36|37|38|41|42|43|44|45|46|47|48|49|51|52|53|54|55|61|62|63|64|65|66|67|68|69|71|72|73|74|75|77|78|79|81|82|83|84|85|86|87|88|89|91|92|93|94|95|96|97|98|99)(?:9\\d{8}|[1-8]\\d{7})$/\n const phone = value.replace(/\\D/g, '')\n if (!phoneRegex.test(phone)) {\n return 'country-forms.validation.invalid'\n }\n return true\n}\n\n// ── CPF ───────────────────────────────────────────────────────────────────────\n\n/**\n * Validates a Brazilian CPF (Cadastro de Pessoas Físicas).\n *\n * Accepts masked (`\"123.456.789-09\"`) and unmasked (`\"12345678909\"`) forms.\n * Rules:\n * - Must contain exactly 11 digits after stripping non-digits.\n * - All identical digits are invalid (e.g. `\"000.000.000-00\"`).\n * - Check digits (positions 10 and 11) must satisfy the Receita Federal algorithm.\n *\n * @param value - CPF string to validate (with or without mask)\n * @returns `true` when valid, or an i18n error key string when invalid\n * @see https://www.macoratti.net/alg_cpf.htm\n */\nexport function validateCPF(value: string): boolean | string {\n const digits = value.replace(/\\D/g, '')\n\n if (digits.length !== 11) return 'country-forms.validation.invalid'\n if (new Set(digits).size === 1) return 'country-forms.validation.invalid'\n\n let sum = 0\n for (let i = 0; i < 9; i++) {\n sum += Number(digits[i]) * (10 - i)\n }\n let remainder = (sum * 10) % 11\n if (remainder === 10) remainder = 0\n if (remainder !== Number(digits[9])) return 'country-forms.validation.invalid'\n\n sum = 0\n for (let i = 0; i < 10; i++) {\n sum += Number(digits[i]) * (11 - i)\n }\n remainder = (sum * 10) % 11\n if (remainder === 10) remainder = 0\n if (remainder !== Number(digits[10])) return 'country-forms.validation.invalid'\n\n return true\n}\n\n// ── CNPJ ──────────────────────────────────────────────────────────────────────\n\nconst CNPJ_TOTAL_LENGTH = 14\nconst CNPJ_BASE_LENGTH = 12\nconst CNPJ_MODULUS = 11\nconst CNPJ_BASE_CHAR_CODE = '0'.charCodeAt(0)\n\n// Shared 13-element weight table. The first check digit uses the last 12 weights\n// (over the 12-character base); the second check digit uses all 13 weights\n// (over base + first check digit). This mirrors the SERPRO reference algorithm.\nconst CNPJ_WEIGHTS = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] as const\n\nconst CNPJ_CLEAN_REGEX = /[./\\-\\s]/g\nconst CNPJ_FORMAT_REGEX = /^[A-Z0-9]{12}[0-9]{2}$/\nconst CNPJ_ALL_ZEROS_REGEX = /^0+$/\n\n/**\n * Computes a CNPJ check digit for the given alphanumeric prefix using the\n * SERPRO algorithm. Each character contributes `charCode - '0'` to the\n * weighted sum: digits `0-9` map to `0-9`, letters `A-Z` map to `17-42`.\n *\n * @internal\n */\nfunction calculateCnpjCheckDigit(prefix: string): number {\n const offset = CNPJ_WEIGHTS.length - prefix.length\n let sum = 0\n for (let i = 0; i < prefix.length; i++) {\n const charValue = prefix.charCodeAt(i) - CNPJ_BASE_CHAR_CODE\n sum += charValue * (CNPJ_WEIGHTS[offset + i] as number)\n }\n const remainder = sum % CNPJ_MODULUS\n return remainder < 2 ? 0 : CNPJ_MODULUS - remainder\n}\n\n/**\n * Validates a Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica).\n *\n * Supports both the legacy numeric format and the new alphanumeric format\n * announced by the Receita Federal (Instrução Normativa RFB 2.229/2024,\n * effective for new registrations from July 2026 onward). Numeric CNPJs\n * already issued remain valid — they are a strict subset of the new format.\n *\n * Accepted inputs:\n * - Masked numeric: `\"11.222.333/0001-81\"`\n * - Unmasked numeric: `\"11222333000181\"`\n * - Masked alphanumeric: `\"12.ABC.345/01DE-35\"`\n * - Unmasked alphanumeric: `\"12ABC34501DE35\"`\n *\n * Lowercase letters are accepted and normalized to uppercase.\n *\n * Rules:\n * - After stripping separators (`.`, `/`, `-`, whitespace), the string must be\n * exactly 14 characters long.\n * - The first 12 characters (base) must be alphanumeric uppercase (`A-Z`, `0-9`).\n * - The last 2 characters (check digits) must be numeric (`0-9`).\n * - All-zeros input is invalid (e.g. `\"00000000000000\"`).\n * - Check digits must satisfy the SERPRO algorithm: each character contributes\n * `charCode - '0'.charCode` to a weighted sum modulo 11.\n *\n * @param value - CNPJ string to validate (with or without mask, numeric or alphanumeric)\n * @returns `true` when valid, or an i18n error key string when invalid\n * @see https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico\n */\nexport function validateCNPJ(value: string): boolean | string {\n if (!value || !value.trim()) return 'country-forms.validation.invalid'\n\n const cleaned = value.trim().toUpperCase().replace(CNPJ_CLEAN_REGEX, '')\n\n if (cleaned.length !== CNPJ_TOTAL_LENGTH) return 'country-forms.validation.invalid'\n if (!CNPJ_FORMAT_REGEX.test(cleaned)) return 'country-forms.validation.invalid'\n if (CNPJ_ALL_ZEROS_REGEX.test(cleaned)) return 'country-forms.validation.invalid'\n\n const base = cleaned.slice(0, CNPJ_BASE_LENGTH)\n const providedCheck1 = Number(cleaned[CNPJ_BASE_LENGTH])\n const providedCheck2 = Number(cleaned[CNPJ_BASE_LENGTH + 1])\n\n const expectedCheck1 = calculateCnpjCheckDigit(base)\n if (providedCheck1 !== expectedCheck1) return 'country-forms.validation.invalid'\n\n const expectedCheck2 = calculateCnpjCheckDigit(base + expectedCheck1)\n if (providedCheck2 !== expectedCheck2) return 'country-forms.validation.invalid'\n\n return true\n}\n\nregisterValidator('validateCEP', validateCEP)\nregisterValidator('validateEmail', validateEmail)\nregisterValidator('validatePhoneBRA', validatePhoneBRA)\nregisterValidator('validateCPF', validateCPF)\nregisterValidator('validateCNPJ', validateCNPJ)\n"]}
|