soff-id 0.1.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/core/index.cjs +2 -0
  4. package/dist/core/index.cjs.map +1 -0
  5. package/dist/core/index.d.cts +63 -0
  6. package/dist/core/index.d.ts +63 -0
  7. package/dist/core/index.js +2 -0
  8. package/dist/core/index.js.map +1 -0
  9. package/dist/index.cjs +2 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +6 -0
  12. package/dist/index.d.ts +6 -0
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/locales/ar.cjs +2 -0
  16. package/dist/locales/ar.cjs.map +1 -0
  17. package/dist/locales/ar.d.cts +42 -0
  18. package/dist/locales/ar.d.ts +42 -0
  19. package/dist/locales/ar.js +2 -0
  20. package/dist/locales/ar.js.map +1 -0
  21. package/dist/locales/br.cjs +2 -0
  22. package/dist/locales/br.cjs.map +1 -0
  23. package/dist/locales/br.d.cts +30 -0
  24. package/dist/locales/br.d.ts +30 -0
  25. package/dist/locales/br.js +2 -0
  26. package/dist/locales/br.js.map +1 -0
  27. package/dist/locales/cl.cjs +2 -0
  28. package/dist/locales/cl.cjs.map +1 -0
  29. package/dist/locales/cl.d.cts +28 -0
  30. package/dist/locales/cl.d.ts +28 -0
  31. package/dist/locales/cl.js +2 -0
  32. package/dist/locales/cl.js.map +1 -0
  33. package/dist/locales/co.cjs +2 -0
  34. package/dist/locales/co.cjs.map +1 -0
  35. package/dist/locales/co.d.cts +48 -0
  36. package/dist/locales/co.d.ts +48 -0
  37. package/dist/locales/co.js +2 -0
  38. package/dist/locales/co.js.map +1 -0
  39. package/dist/locales/mx.cjs +2 -0
  40. package/dist/locales/mx.cjs.map +1 -0
  41. package/dist/locales/mx.d.cts +38 -0
  42. package/dist/locales/mx.d.ts +38 -0
  43. package/dist/locales/mx.js +2 -0
  44. package/dist/locales/mx.js.map +1 -0
  45. package/package.json +156 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Luis C. Rojas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # soff-id 🪪
2
+
3
+ LATAM document validation library - Validate NIT, RUT, CPF, CUIT, and more.
4
+
5
+ ## The Problem
6
+
7
+ Validating a NIT in Colombia (calculating the verification digit), a RUT in Chile, a CPF in Brazil, or a CUIT in Argentina is something that all developers in the region have to reprogram over and over again.
8
+
9
+ ## The Solution
10
+
11
+ A modular, tree-shakeable library using the same architecture as `soff-date`. Import only the validators you need.
12
+
13
+ ## Features
14
+
15
+ - 🔢 **Accurate validation** - Uses official algorithms for each document type
16
+ - 🌎 **LATAM coverage** - CO, BR, AR, CL, MX
17
+ - 🌳 **Tree-shakeable** - Import only what you need
18
+ - 📦 **Tiny bundle** - Each locale is < 1KB gzipped
19
+ - 💯 **TypeScript** - Full type safety
20
+ - ⚡ **Zero dependencies** - Pure JavaScript
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install soff-id
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```typescript
31
+ // Import only what you need
32
+ import { validateNIT, formatNIT, calculateNITCheckDigit } from 'soff-id/locales/co';
33
+ import { validateCPF, validateCNPJ } from 'soff-id/locales/br';
34
+ import { validateRUT } from 'soff-id/locales/cl';
35
+ import { validateCUIT } from 'soff-id/locales/ar';
36
+
37
+ // Colombian NIT
38
+ validateNIT('900123456-7'); // true
39
+ calculateNITCheckDigit('900123456'); // '7'
40
+ formatNIT('9001234567'); // '900.123.456-7'
41
+
42
+ // Brazilian CPF
43
+ validateCPF('123.456.789-09'); // true/false
44
+
45
+ // Chilean RUT
46
+ validateRUT('12.345.678-5'); // true/false
47
+
48
+ // Argentine CUIT
49
+ validateCUIT('20-12345678-9'); // true/false
50
+ ```
51
+
52
+ ## Available Locales
53
+
54
+ | Locale | Documents | Description |
55
+ | ------ | --------------- | ---------------------------------------------------- |
56
+ | `co` | NIT, CC, CE, TI | Colombia - Tax ID, Cédula, Foreign ID, Identity Card |
57
+ | `br` | CPF, CNPJ | Brazil - Individual & Business Tax IDs |
58
+ | `ar` | DNI, CUIT, CUIL | Argentina - National ID & Tax IDs |
59
+ | `cl` | RUT, RUN | Chile - Tax ID & National ID |
60
+ | `mx` | RFC, CURP | Mexico - Tax ID & Personal ID |
61
+
62
+ ## Validation API
63
+
64
+ Each locale exports:
65
+
66
+ - `validate{DOC}(value)` - Returns `boolean`
67
+ - `format{DOC}(value)` - Returns formatted string
68
+ - `clean{DOC}(value)` - Removes formatting
69
+ - `calculate{DOC}CheckDigit(value)` - Returns check digit (where applicable)
70
+
71
+ ## License
72
+
73
+ MIT
@@ -0,0 +1,2 @@
1
+ 'use strict';function a(t){return t.replace(/[^a-zA-Z0-9]/g,"")}function u(t){return t.replace(/\D/g,"")}function i(t,n){return t.padStart(n,"0")}function l(t,n){let e=0;for(let r=0;r<t.length;r++)e+=parseInt(t[r],10)*n[r%n.length];return e%11}function m(t,n){let e=0;for(let o=0;o<t.length;o++){let r=parseInt(t[o],10)*n[o%n.length];r>9&&(r=Math.floor(r/10)+r%10),e+=r;}return e%10}exports.cleanDigits=u;exports.cleanDocument=a;exports.mod10=m;exports.mod11=l;exports.padStart=i;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/utils.ts"],"names":["cleanDocument","value","cleanDigits","padStart","length","mod11","digits","weights","sum","i","mod10","product"],"mappings":"aAGO,SAASA,CAAAA,CAAcC,CAAAA,CAAuB,CACnD,OAAOA,CAAAA,CAAM,QAAQ,eAAA,CAAiB,EAAE,CAC1C,CAKO,SAASC,CAAAA,CAAYD,EAAuB,CACjD,OAAOA,CAAAA,CAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAeG,CAAAA,CAAwB,CAC9D,OAAOH,CAAAA,CAAM,QAAA,CAASG,CAAAA,CAAQ,GAAG,CACnC,CAKO,SAASC,CAAAA,CAAMC,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,EACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,CAAAA,CAAO,MAAA,CAAQG,IACjCD,CAAAA,EAAO,QAAA,CAASF,CAAAA,CAAOG,CAAC,CAAA,CAAG,EAAE,EAAIF,CAAAA,CAAQE,CAAAA,CAAIF,CAAAA,CAAQ,MAAM,CAAA,CAG7D,OADkBC,EAAM,EAE1B,CAKO,SAASE,CAAAA,CAAMJ,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,CAAA,CACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,EAAIH,CAAAA,CAAO,MAAA,CAAQG,CAAAA,EAAAA,CAAK,CACtC,IAAIE,CAAAA,CAAU,SAASL,CAAAA,CAAOG,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIF,CAAAA,CAAQE,EAAIF,CAAAA,CAAQ,MAAM,CAAA,CAC9DI,CAAAA,CAAU,CAAA,GACZA,CAAAA,CAAU,KAAK,KAAA,CAAMA,CAAAA,CAAU,EAAE,CAAA,CAAKA,CAAAA,CAAU,EAAA,CAAA,CAElDH,GAAOG,EACT,CACA,OAAOH,CAAAA,CAAM,EACf","file":"index.cjs","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n"]}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Remove all non-alphanumeric characters
3
+ */
4
+ declare function cleanDocument(value: string): string;
5
+ /**
6
+ * Remove all non-digit characters
7
+ */
8
+ declare function cleanDigits(value: string): string;
9
+ /**
10
+ * Pad a string with leading zeros
11
+ */
12
+ declare function padStart(value: string, length: number): string;
13
+ /**
14
+ * Calculate modulo 11 check digit (common algorithm)
15
+ */
16
+ declare function mod11(digits: string, weights: number[]): number;
17
+ /**
18
+ * Calculate modulo 10 check digit (Luhn-like algorithms)
19
+ */
20
+ declare function mod10(digits: string, weights: number[]): number;
21
+
22
+ /**
23
+ * Result of a document validation
24
+ */
25
+ interface ValidationResult {
26
+ /** Whether the document is valid */
27
+ valid: boolean;
28
+ /** Error message if invalid */
29
+ error?: string;
30
+ /** The cleaned/normalized value */
31
+ cleaned?: string;
32
+ /** The formatted value */
33
+ formatted?: string;
34
+ }
35
+ /**
36
+ * Document type configuration
37
+ */
38
+ interface DocumentType {
39
+ /** Document type code */
40
+ code: string;
41
+ /** Human-readable name */
42
+ name: string;
43
+ /** Country code (ISO 3166-1 alpha-2) */
44
+ country: string;
45
+ /** Regular expression for valid format */
46
+ pattern: RegExp;
47
+ /** Validate the document */
48
+ validate: (value: string) => boolean;
49
+ /** Format the document for display */
50
+ format: (value: string) => string;
51
+ /** Clean/normalize the document (remove formatting) */
52
+ clean: (value: string) => string;
53
+ }
54
+ /**
55
+ * Validator function type
56
+ */
57
+ type ValidatorFn = (value: string) => boolean;
58
+ /**
59
+ * Formatter function type
60
+ */
61
+ type FormatterFn = (value: string) => string;
62
+
63
+ export { type DocumentType, type FormatterFn, type ValidationResult, type ValidatorFn, cleanDigits, cleanDocument, mod10, mod11, padStart };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Remove all non-alphanumeric characters
3
+ */
4
+ declare function cleanDocument(value: string): string;
5
+ /**
6
+ * Remove all non-digit characters
7
+ */
8
+ declare function cleanDigits(value: string): string;
9
+ /**
10
+ * Pad a string with leading zeros
11
+ */
12
+ declare function padStart(value: string, length: number): string;
13
+ /**
14
+ * Calculate modulo 11 check digit (common algorithm)
15
+ */
16
+ declare function mod11(digits: string, weights: number[]): number;
17
+ /**
18
+ * Calculate modulo 10 check digit (Luhn-like algorithms)
19
+ */
20
+ declare function mod10(digits: string, weights: number[]): number;
21
+
22
+ /**
23
+ * Result of a document validation
24
+ */
25
+ interface ValidationResult {
26
+ /** Whether the document is valid */
27
+ valid: boolean;
28
+ /** Error message if invalid */
29
+ error?: string;
30
+ /** The cleaned/normalized value */
31
+ cleaned?: string;
32
+ /** The formatted value */
33
+ formatted?: string;
34
+ }
35
+ /**
36
+ * Document type configuration
37
+ */
38
+ interface DocumentType {
39
+ /** Document type code */
40
+ code: string;
41
+ /** Human-readable name */
42
+ name: string;
43
+ /** Country code (ISO 3166-1 alpha-2) */
44
+ country: string;
45
+ /** Regular expression for valid format */
46
+ pattern: RegExp;
47
+ /** Validate the document */
48
+ validate: (value: string) => boolean;
49
+ /** Format the document for display */
50
+ format: (value: string) => string;
51
+ /** Clean/normalize the document (remove formatting) */
52
+ clean: (value: string) => string;
53
+ }
54
+ /**
55
+ * Validator function type
56
+ */
57
+ type ValidatorFn = (value: string) => boolean;
58
+ /**
59
+ * Formatter function type
60
+ */
61
+ type FormatterFn = (value: string) => string;
62
+
63
+ export { type DocumentType, type FormatterFn, type ValidationResult, type ValidatorFn, cleanDigits, cleanDocument, mod10, mod11, padStart };
@@ -0,0 +1,2 @@
1
+ function a(t){return t.replace(/[^a-zA-Z0-9]/g,"")}function u(t){return t.replace(/\D/g,"")}function i(t,n){return t.padStart(n,"0")}function l(t,n){let e=0;for(let r=0;r<t.length;r++)e+=parseInt(t[r],10)*n[r%n.length];return e%11}function m(t,n){let e=0;for(let o=0;o<t.length;o++){let r=parseInt(t[o],10)*n[o%n.length];r>9&&(r=Math.floor(r/10)+r%10),e+=r;}return e%10}export{u as cleanDigits,a as cleanDocument,m as mod10,l as mod11,i as padStart};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/utils.ts"],"names":["cleanDocument","value","cleanDigits","padStart","length","mod11","digits","weights","sum","i","mod10","product"],"mappings":"AAGO,SAASA,CAAAA,CAAcC,CAAAA,CAAuB,CACnD,OAAOA,CAAAA,CAAM,QAAQ,eAAA,CAAiB,EAAE,CAC1C,CAKO,SAASC,CAAAA,CAAYD,EAAuB,CACjD,OAAOA,CAAAA,CAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAeG,CAAAA,CAAwB,CAC9D,OAAOH,CAAAA,CAAM,QAAA,CAASG,CAAAA,CAAQ,GAAG,CACnC,CAKO,SAASC,CAAAA,CAAMC,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,EACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,CAAAA,CAAO,MAAA,CAAQG,IACjCD,CAAAA,EAAO,QAAA,CAASF,CAAAA,CAAOG,CAAC,CAAA,CAAG,EAAE,EAAIF,CAAAA,CAAQE,CAAAA,CAAIF,CAAAA,CAAQ,MAAM,CAAA,CAG7D,OADkBC,EAAM,EAE1B,CAKO,SAASE,CAAAA,CAAMJ,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,CAAA,CACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,EAAIH,CAAAA,CAAO,MAAA,CAAQG,CAAAA,EAAAA,CAAK,CACtC,IAAIE,CAAAA,CAAU,SAASL,CAAAA,CAAOG,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIF,CAAAA,CAAQE,EAAIF,CAAAA,CAAQ,MAAM,CAAA,CAC9DI,CAAAA,CAAU,CAAA,GACZA,CAAAA,CAAU,KAAK,KAAA,CAAMA,CAAAA,CAAU,EAAE,CAAA,CAAKA,CAAAA,CAAU,EAAA,CAAA,CAElDH,GAAOG,EACT,CACA,OAAOH,CAAAA,CAAM,EACf","file":"index.js","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';function a(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function o(e){return e.replace(/\D/g,"")}function T(e,t){return e.padStart(t,"0")}function R(e,t){let r=0;for(let n=0;n<e.length;n++)r+=parseInt(e[n],10)*t[n%t.length];return r%11}function D(e,t){let r=0;for(let i=0;i<e.length;i++){let n=parseInt(e[i],10)*t[i%t.length];n>9&&(n=Math.floor(n/10)+n%10),r+=n;}return r%10}var v=[3,7,13,17,19,23,29,37,41,43,47,53,59,67,71];function g(e){let t=o(e);if(t.length<8||t.length>15)throw new Error("NIT must be between 8 and 15 digits");let r=0,i=t.split("").reverse();for(let c=0;c<i.length;c++)r+=parseInt(i[c],10)*v[c];let n=r%11;return n===0?"0":n===1?"1":String(11-n)}function N(e){let t=o(e);if(t.length<9||t.length>16)return false;let r=t.slice(0,-1),i=t.slice(-1);try{return g(r)===i}catch{return false}}function P(e){let t=o(e);if(t.length<9)return e;let r=t.slice(0,-1),i=t.slice(-1);return `${r.replace(/\B(?=(\d{3})+(?!\d))/g,".")}-${i}`}function b(e){return o(e)}function F(e){let t=o(e);return t.length>=6&&t.length<=10}function $(e){return o(e).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function y(e){return o(e)}function S(e){let t=o(e);return t.length>=6&&t.length<=10}function k(e){let t=o(e);return t.length>=10&&t.length<=11}var _=[10,9,8,7,6,5,4,3,2],E=[11,10,9,8,7,6,5,4,3,2],A=[5,4,3,2,9,8,7,6,5,4,3,2],G=[6,5,4,3,2,9,8,7,6,5,4,3,2];function u(e,t){let r=0;for(let n=0;n<t.length;n++)r+=parseInt(e[n],10)*t[n];let i=r%11;return i<2?0:11-i}function H(e){let t=o(e);return t.length!==11||/^(\d)\1+$/.test(t)||u(t.slice(0,9),_)!==parseInt(t[9],10)?false:u(t.slice(0,10),E)===parseInt(t[10],10)}function J(e){let t=o(e).padStart(11,"0");return `${t.slice(0,3)}.${t.slice(3,6)}.${t.slice(6,9)}-${t.slice(9)}`}function L(e){return o(e)}function Z(e){let t=o(e);return t.length!==14||/^(\d)\1+$/.test(t)||u(t.slice(0,12),A)!==parseInt(t[12],10)?false:u(t.slice(0,13),G)===parseInt(t[13],10)}function M(e){let t=o(e).padStart(14,"0");return `${t.slice(0,2)}.${t.slice(2,5)}.${t.slice(5,8)}/${t.slice(8,12)}-${t.slice(12)}`}function W(e){return o(e)}var f=[2,3,4,5,6,7];function d(e){let r=o(e).split("").reverse(),i=0;for(let c=0;c<r.length;c++)i+=parseInt(r[c],10)*f[c%f.length];let n=11-i%11;return n===11?"0":n===10?"K":String(n)}function p(e){let t=a(e).toUpperCase();if(t.length<8||t.length>9)return false;let r=t.slice(0,-1),i=t.slice(-1);return /^\d+$/.test(r)?d(r)===i:false}function C(e){let t=a(e).toUpperCase();if(t.length<2)return e;let r=t.slice(0,-1),i=t.slice(-1);return `${r.replace(/\B(?=(\d{3})+(?!\d))/g,".")}-${i}`}function m(e){return a(e).toUpperCase()}var B=p,w=C,O=m;var V=[5,4,3,2,7,6,5,4,3,2];function I(e){let t=o(e);if(t.length!==10)throw new Error("CUIT body must be 10 digits");let r=0;for(let n=0;n<10;n++)r+=parseInt(t[n],10)*V[n];let i=11-r%11;return i===11?"0":i===10?"9":String(i)}function h(e){let t=o(e);if(t.length!==11)return false;let r=t.slice(0,2);if(!["20","23","24","27","30","33","34"].includes(r))return false;let n=t.slice(0,10),c=t.slice(-1);try{return I(n)===c}catch{return false}}function U(e){let t=o(e).padStart(11,"0");return `${t.slice(0,2)}-${t.slice(2,10)}-${t.slice(10)}`}function x(e){return o(e)}var K=h,Y=U,j=x;function z(e){let t=o(e);return t.length>=7&&t.length<=8}function Q(e){return o(e).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function X(e){return o(e)}var q=/^[A-ZÑ&]{4}\d{6}[A-Z0-9]{3}$/,tt=/^[A-ZÑ&]{3}\d{6}[A-Z0-9]{3}$/,et=/^[A-Z]{4}\d{6}[HM][A-Z]{5}[A-Z0-9]\d$/;function nt(e){let t=a(e).toUpperCase();return t.length!==12&&t.length!==13?false:t.length===13?q.test(t):tt.test(t)}function rt(e){return a(e).toUpperCase()}function it(e){return a(e).toUpperCase()}function ot(e){let t=a(e).toUpperCase();return t.length!==18||!et.test(t)?false:ct(t)}function ct(e){let t="0123456789ABCDEFGHIJKLMN\xD1OPQRSTUVWXYZ",r=0;for(let n=0;n<17;n++){let c=e[n],s=t.indexOf(c);if(s===-1)return false;r+=s*(18-n);}return (10-r%10)%10===parseInt(e[17],10)}function at(e){return a(e).toUpperCase()}function st(e){return a(e).toUpperCase()}function lt(e){let t=a(e).toUpperCase();if(t.length<11)return null;let r=t[10];return r==="H"?"M":r==="M"?"F":null}function ut(e){let t=a(e).toUpperCase();if(t.length<10)return null;let r=t.slice(4,6),i=t.slice(6,8),n=t.slice(8,10),c=t[16],s;/\d/.test(c)?s=1900+parseInt(r,10):s=2e3+parseInt(r,10);let l=new Date(s,parseInt(i,10)-1,parseInt(n,10));return l.getFullYear()!==s||l.getMonth()!==parseInt(i,10)-1||l.getDate()!==parseInt(n,10)?null:l}exports.calculateCUITCheckDigit=I;exports.calculateNITCheckDigit=g;exports.calculateRUTCheckDigit=d;exports.cleanCC=y;exports.cleanCNPJ=W;exports.cleanCPF=L;exports.cleanCUIL=j;exports.cleanCUIT=x;exports.cleanCURP=st;exports.cleanDNI=X;exports.cleanDigits=o;exports.cleanDocument=a;exports.cleanNIT=b;exports.cleanRFC=it;exports.cleanRUN=O;exports.cleanRUT=m;exports.formatCC=$;exports.formatCNPJ=M;exports.formatCPF=J;exports.formatCUIL=Y;exports.formatCUIT=U;exports.formatCURP=at;exports.formatDNI=Q;exports.formatNIT=P;exports.formatRFC=rt;exports.formatRUN=w;exports.formatRUT=C;exports.getCURPBirthDate=ut;exports.getCURPGender=lt;exports.mod10=D;exports.mod11=R;exports.padStart=T;exports.validateCC=F;exports.validateCE=S;exports.validateCNPJ=Z;exports.validateCPF=H;exports.validateCUIL=K;exports.validateCUIT=h;exports.validateCURP=ot;exports.validateDNI=z;exports.validateNIT=N;exports.validateRFC=nt;exports.validateRUN=B;exports.validateRUT=p;exports.validateTI=k;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/utils.ts","../src/locales/co.ts","../src/locales/br.ts","../src/locales/cl.ts","../src/locales/ar.ts","../src/locales/mx.ts"],"names":["cleanDocument","value","cleanDigits","padStart","length","mod11","digits","weights","sum","i","mod10","product","NIT_WEIGHTS","calculateNITCheckDigit","nit","cleaned","reversed","remainder","validateNIT","body","checkDigit","formatNIT","cleanNIT","validateCC","cc","formatCC","cleanCC","validateCE","ce","validateTI","ti","CPF_WEIGHTS_1","CPF_WEIGHTS_2","CNPJ_WEIGHTS_1","CNPJ_WEIGHTS_2","calcCheckDigit","validateCPF","cpf","formatCPF","cleanCPF","validateCNPJ","cnpj","formatCNPJ","cleanCNPJ","RUT_WEIGHTS","calculateRUTCheckDigit","rut","validateRUT","formatRUT","cleanRUT","validateRUN","formatRUN","cleanRUN","CUIT_WEIGHTS","calculateCUITCheckDigit","cuit","validateCUIT","type","formatCUIT","cleanCUIT","validateCUIL","formatCUIL","cleanCUIL","validateDNI","dni","formatDNI","cleanDNI","RFC_PATTERN_FISICA","RFC_PATTERN_MORAL","CURP_PATTERN","validateRFC","rfc","formatRFC","cleanRFC","validateCURP","curp","validateCURPCheckDigit","dictionary","char","formatCURP","cleanCURP","getCURPGender","genderChar","getCURPBirthDate","yearPart","month","day","centuryChar","year","date"],"mappings":"aAGO,SAASA,EAAcC,CAAAA,CAAuB,CACnD,OAAOA,CAAAA,CAAM,QAAQ,eAAA,CAAiB,EAAE,CAC1C,CAKO,SAASC,CAAAA,CAAYD,CAAAA,CAAuB,CACjD,OAAOA,EAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAeG,CAAAA,CAAwB,CAC9D,OAAOH,CAAAA,CAAM,QAAA,CAASG,CAAAA,CAAQ,GAAG,CACnC,CAKO,SAASC,CAAAA,CAAMC,EAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,EACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,EAAO,MAAA,CAAQG,CAAAA,EAAAA,CACjCD,CAAAA,EAAO,QAAA,CAASF,EAAOG,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIF,EAAQE,CAAAA,CAAIF,CAAAA,CAAQ,MAAM,CAAA,CAG7D,OADkBC,CAAAA,CAAM,EAE1B,CAKO,SAASE,EAAMJ,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,EAAM,CAAA,CACV,IAAA,IAAS,EAAI,CAAA,CAAG,CAAA,CAAIF,EAAO,MAAA,CAAQ,CAAA,EAAA,CAAK,CACtC,IAAIK,EAAU,QAAA,CAASL,CAAAA,CAAO,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIC,CAAAA,CAAQ,CAAA,CAAIA,CAAAA,CAAQ,MAAM,CAAA,CAC9DI,CAAAA,CAAU,CAAA,GACZA,CAAAA,CAAU,KAAK,KAAA,CAAMA,CAAAA,CAAU,EAAE,CAAA,CAAKA,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A,CAAY,GAAA,CACxB,IACT,CAMO,SAASC,EAAAA,CAAiBR,CAAAA,CAA2B,CAC1D,IAAM5D,CAAAA,CAAUf,CAAAA,CAAc2E,CAAI,CAAA,CAAE,WAAA,GACpC,GAAI5D,CAAAA,CAAQ,MAAA,CAAS,EAAA,CAAI,OAAO,IAAA,CAEhC,IAAMqE,CAAAA,CAAWrE,CAAAA,CAAQ,MAAM,CAAA,CAAG,CAAC,CAAA,CAC7BsE,CAAAA,CAAQtE,EAAQ,KAAA,CAAM,CAAA,CAAG,CAAC,CAAA,CAC1BuE,EAAMvE,CAAAA,CAAQ,KAAA,CAAM,CAAA,CAAG,EAAE,EAIzBwE,CAAAA,CAAcxE,CAAAA,CAAQ,EAAE,CAAA,CAC1ByE,EAEA,IAAA,CAAK,IAAA,CAAKD,CAAW,CAAA,CACvBC,EAAO,IAAA,CAAO,QAAA,CAASJ,EAAU,EAAE,CAAA,CAEnCI,EAAO,GAAA,CAAO,QAAA,CAASJ,CAAAA,CAAU,EAAE,EAGrC,IAAMK,CAAAA,CAAO,IAAI,IAAA,CAAKD,EAAM,QAAA,CAASH,CAAAA,CAAO,EAAE,CAAA,CAAI,EAAG,QAAA,CAASC,CAAAA,CAAK,EAAE,CAAC,EAGtE,OACEG,CAAAA,CAAK,WAAA,EAAY,GAAMD,GACvBC,CAAAA,CAAK,QAAA,EAAS,GAAM,QAAA,CAASJ,EAAO,EAAE,CAAA,CAAI,CAAA,EAC1CI,CAAAA,CAAK,SAAQ,GAAM,QAAA,CAASH,EAAK,EAAE,CAAA,CAE5B,KAGFG,CACT","file":"index.cjs","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * NIT verification weights (Colombian tax ID)\n * Algorithm: Multiply each digit by its weight, sum, mod 11\n */\nconst NIT_WEIGHTS = [3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71];\n\n/**\n * Calculate the NIT check digit\n * @param nit - The NIT without check digit (8-15 digits)\n * @returns The check digit (0-9)\n */\nexport function calculateNITCheckDigit(nit: string): string {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 8 || cleaned.length > 15) {\n throw new Error('NIT must be between 8 and 15 digits');\n }\n\n let sum = 0;\n const reversed = cleaned.split('').reverse();\n\n for (let i = 0; i < reversed.length; i++) {\n sum += parseInt(reversed[i], 10) * NIT_WEIGHTS[i];\n }\n\n const remainder = sum % 11;\n\n if (remainder === 0) return '0';\n if (remainder === 1) return '1';\n return String(11 - remainder);\n}\n\n/**\n * Validate a Colombian NIT\n * @param nit - The NIT to validate (with or without check digit)\n * @returns true if valid\n */\nexport function validateNIT(nit: string): boolean {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 9 || cleaned.length > 16) {\n return false;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateNITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a NIT for display\n * @param nit - The NIT to format\n * @returns Formatted NIT (e.g., \"900.123.456-7\")\n */\nexport function formatNIT(nit: string): string {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 9) {\n return nit;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Format with dots every 3 digits from right\n const formatted = body.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n\n return `${formatted}-${checkDigit}`;\n}\n\n/**\n * Clean a NIT (remove all formatting)\n */\nexport function cleanNIT(nit: string): string {\n return cleanDigits(nit);\n}\n\n/**\n * Validate a Colombian Cédula de Ciudadanía (CC)\n * @param cc - The CC number (6-10 digits)\n * @returns true if valid format\n */\nexport function validateCC(cc: string): boolean {\n const cleaned = cleanDigits(cc);\n return cleaned.length >= 6 && cleaned.length <= 10;\n}\n\n/**\n * Format a Cédula for display\n */\nexport function formatCC(cc: string): string {\n const cleaned = cleanDigits(cc);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a Cédula\n */\nexport function cleanCC(cc: string): string {\n return cleanDigits(cc);\n}\n\n/**\n * Validate a Cédula de Extranjería (CE)\n * @param ce - The CE number (6-10 digits)\n */\nexport function validateCE(ce: string): boolean {\n const cleaned = cleanDigits(ce);\n return cleaned.length >= 6 && cleaned.length <= 10;\n}\n\n/**\n * Validate a Tarjeta de Identidad (TI)\n * @param ti - The TI number (10-11 digits)\n */\nexport function validateTI(ti: string): boolean {\n const cleaned = cleanDigits(ti);\n return cleaned.length >= 10 && cleaned.length <= 11;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CPF weights for first check digit\n */\nconst CPF_WEIGHTS_1 = [10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CPF weights for second check digit\n */\nconst CPF_WEIGHTS_2 = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for first check digit\n */\nconst CNPJ_WEIGHTS_1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for second check digit\n */\nconst CNPJ_WEIGHTS_2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CPF/CNPJ check digit using mod 11\n */\nfunction calcCheckDigit(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < weights.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i];\n }\n const remainder = sum % 11;\n return remainder < 2 ? 0 : 11 - remainder;\n}\n\n/**\n * Validate a Brazilian CPF (Individual Tax ID)\n * @param cpf - The CPF to validate (11 digits)\n */\nexport function validateCPF(cpf: string): boolean {\n const cleaned = cleanDigits(cpf);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Check for known invalid CPFs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 9), CPF_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[9], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 10), CPF_WEIGHTS_2);\n return digit2 === parseInt(cleaned[10], 10);\n}\n\n/**\n * Format a CPF for display\n * @returns Formatted CPF (e.g., \"123.456.789-09\")\n */\nexport function formatCPF(cpf: string): string {\n const cleaned = cleanDigits(cpf).padStart(11, '0');\n return `${cleaned.slice(0, 3)}.${cleaned.slice(3, 6)}.${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;\n}\n\n/**\n * Clean a CPF\n */\nexport function cleanCPF(cpf: string): string {\n return cleanDigits(cpf);\n}\n\n/**\n * Validate a Brazilian CNPJ (Business Tax ID)\n * @param cnpj - The CNPJ to validate (14 digits)\n */\nexport function validateCNPJ(cnpj: string): boolean {\n const cleaned = cleanDigits(cnpj);\n\n if (cleaned.length !== 14) {\n return false;\n }\n\n // Check for known invalid CNPJs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 12), CNPJ_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[12], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 13), CNPJ_WEIGHTS_2);\n return digit2 === parseInt(cleaned[13], 10);\n}\n\n/**\n * Format a CNPJ for display\n * @returns Formatted CNPJ (e.g., \"12.345.678/0001-95\")\n */\nexport function formatCNPJ(cnpj: string): string {\n const cleaned = cleanDigits(cnpj).padStart(14, '0');\n return `${cleaned.slice(0, 2)}.${cleaned.slice(2, 5)}.${cleaned.slice(5, 8)}/${cleaned.slice(8, 12)}-${cleaned.slice(12)}`;\n}\n\n/**\n * Clean a CNPJ\n */\nexport function cleanCNPJ(cnpj: string): string {\n return cleanDigits(cnpj);\n}\n","import { cleanDocument, cleanDigits } from '../core/utils.js';\n\n/**\n * RUT/RUN validation weights\n */\nconst RUT_WEIGHTS = [2, 3, 4, 5, 6, 7];\n\n/**\n * Calculate RUT check digit\n * @param rut - The RUT body (without check digit)\n * @returns The check digit (0-9 or 'K')\n */\nexport function calculateRUTCheckDigit(rut: string): string {\n const cleaned = cleanDigits(rut);\n const reversed = cleaned.split('').reverse();\n\n let sum = 0;\n for (let i = 0; i < reversed.length; i++) {\n sum += parseInt(reversed[i], 10) * RUT_WEIGHTS[i % RUT_WEIGHTS.length];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return 'K';\n return String(remainder);\n}\n\n/**\n * Validate a Chilean RUT (Rol Único Tributario)\n * @param rut - The RUT to validate (e.g., \"12.345.678-5\" or \"12345678-K\")\n */\nexport function validateRUT(rut: string): boolean {\n const cleaned = cleanDocument(rut).toUpperCase();\n\n if (cleaned.length < 8 || cleaned.length > 9) {\n return false;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Body must be all digits\n if (!/^\\d+$/.test(body)) {\n return false;\n }\n\n return calculateRUTCheckDigit(body) === checkDigit;\n}\n\n/**\n * Format a RUT for display\n * @returns Formatted RUT (e.g., \"12.345.678-5\")\n */\nexport function formatRUT(rut: string): string {\n const cleaned = cleanDocument(rut).toUpperCase();\n\n if (cleaned.length < 2) {\n return rut;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Format with dots every 3 digits from right\n const formatted = body.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n\n return `${formatted}-${checkDigit}`;\n}\n\n/**\n * Clean a RUT\n */\nexport function cleanRUT(rut: string): string {\n return cleanDocument(rut).toUpperCase();\n}\n\n/**\n * Validate a Chilean RUN (same algorithm as RUT)\n */\nexport const validateRUN = validateRUT;\nexport const formatRUN = formatRUT;\nexport const cleanRUN = cleanRUT;\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CUIT/CUIL weights\n */\nconst CUIT_WEIGHTS = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CUIT/CUIL check digit\n * @param cuit - The CUIT body (10 digits: type + DNI)\n * @returns The check digit (0-9)\n */\nexport function calculateCUITCheckDigit(cuit: string): string {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 10) {\n throw new Error('CUIT body must be 10 digits');\n }\n\n let sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += parseInt(cleaned[i], 10) * CUIT_WEIGHTS[i];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return '9'; // Special case for Argentina\n return String(remainder);\n}\n\n/**\n * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)\n * @param cuit - The CUIT to validate (e.g., \"20-12345678-9\")\n */\nexport function validateCUIT(cuit: string): boolean {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Valid type prefixes: 20, 23, 24, 27, 30, 33, 34\n const type = cleaned.slice(0, 2);\n const validTypes = ['20', '23', '24', '27', '30', '33', '34'];\n if (!validTypes.includes(type)) {\n return false;\n }\n\n const body = cleaned.slice(0, 10);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateCUITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a CUIT for display\n * @returns Formatted CUIT (e.g., \"20-12345678-9\")\n */\nexport function formatCUIT(cuit: string): string {\n const cleaned = cleanDigits(cuit).padStart(11, '0');\n return `${cleaned.slice(0, 2)}-${cleaned.slice(2, 10)}-${cleaned.slice(10)}`;\n}\n\n/**\n * Clean a CUIT\n */\nexport function cleanCUIT(cuit: string): string {\n return cleanDigits(cuit);\n}\n\n/**\n * CUIL validation (same algorithm as CUIT)\n */\nexport const validateCUIL = validateCUIT;\nexport const formatCUIL = formatCUIT;\nexport const cleanCUIL = cleanCUIT;\nexport const calculateCUILCheckDigit = calculateCUITCheckDigit;\n\n/**\n * Validate an Argentine DNI\n * @param dni - The DNI number (7-8 digits)\n */\nexport function validateDNI(dni: string): boolean {\n const cleaned = cleanDigits(dni);\n return cleaned.length >= 7 && cleaned.length <= 8;\n}\n\n/**\n * Format a DNI for display\n */\nexport function formatDNI(dni: string): string {\n const cleaned = cleanDigits(dni);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a DNI\n */\nexport function cleanDNI(dni: string): string {\n return cleanDigits(dni);\n}\n","import { cleanDocument } from '../core/utils.js';\n\n/**\n * Valid RFC patterns\n * - Persona física: 4 letters + 6 digits + 3 alphanumeric (homoclave)\n * - Persona moral: 3 letters + 6 digits + 3 alphanumeric (homoclave)\n */\nconst RFC_PATTERN_FISICA = /^[A-ZÑ&]{4}\\d{6}[A-Z0-9]{3}$/;\nconst RFC_PATTERN_MORAL = /^[A-ZÑ&]{3}\\d{6}[A-Z0-9]{3}$/;\n\n/**\n * CURP pattern\n * 18 characters: 4 letters + 6 digits + 6 letters + 2 alphanumeric\n */\nconst CURP_PATTERN = /^[A-Z]{4}\\d{6}[HM][A-Z]{5}[A-Z0-9]\\d$/;\n\n/**\n * Validate a Mexican RFC (Registro Federal de Contribuyentes)\n * @param rfc - The RFC to validate\n */\nexport function validateRFC(rfc: string): boolean {\n const cleaned = cleanDocument(rfc).toUpperCase();\n\n if (cleaned.length !== 12 && cleaned.length !== 13) {\n return false;\n }\n\n // 12 chars = Persona moral, 13 chars = Persona física\n if (cleaned.length === 13) {\n return RFC_PATTERN_FISICA.test(cleaned);\n }\n\n return RFC_PATTERN_MORAL.test(cleaned);\n}\n\n/**\n * Format an RFC for display (uppercase, no separators)\n */\nexport function formatRFC(rfc: string): string {\n return cleanDocument(rfc).toUpperCase();\n}\n\n/**\n * Clean an RFC\n */\nexport function cleanRFC(rfc: string): string {\n return cleanDocument(rfc).toUpperCase();\n}\n\n/**\n * Validate a Mexican CURP (Clave Única de Registro de Población)\n * @param curp - The CURP to validate (18 characters)\n */\nexport function validateCURP(curp: string): boolean {\n const cleaned = cleanDocument(curp).toUpperCase();\n\n if (cleaned.length !== 18) {\n return false;\n }\n\n if (!CURP_PATTERN.test(cleaned)) {\n return false;\n }\n\n // Validate check digit\n return validateCURPCheckDigit(cleaned);\n}\n\n/**\n * CURP check digit validation\n */\nfunction validateCURPCheckDigit(curp: string): boolean {\n const dictionary = '0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZ';\n let sum = 0;\n\n for (let i = 0; i < 17; i++) {\n const char = curp[i];\n const value = dictionary.indexOf(char);\n if (value === -1) return false;\n sum += value * (18 - i);\n }\n\n const checkDigit = (10 - (sum % 10)) % 10;\n return checkDigit === parseInt(curp[17], 10);\n}\n\n/**\n * Format a CURP for display\n */\nexport function formatCURP(curp: string): string {\n return cleanDocument(curp).toUpperCase();\n}\n\n/**\n * Clean a CURP\n */\nexport function cleanCURP(curp: string): string {\n return cleanDocument(curp).toUpperCase();\n}\n\n/**\n * Get the gender from a CURP\n * @returns 'M' for male, 'F' for female, or null if invalid\n */\nexport function getCURPGender(curp: string): 'M' | 'F' | null {\n const cleaned = cleanDocument(curp).toUpperCase();\n if (cleaned.length < 11) return null;\n\n const genderChar = cleaned[10];\n if (genderChar === 'H') return 'M';\n if (genderChar === 'M') return 'F';\n return null;\n}\n\n/**\n * Get the birth date from a CURP\n * @returns Date object or null if invalid\n */\nexport function getCURPBirthDate(curp: string): Date | null {\n const cleaned = cleanDocument(curp).toUpperCase();\n if (cleaned.length < 10) return null;\n\n const yearPart = cleaned.slice(4, 6);\n const month = cleaned.slice(6, 8);\n const day = cleaned.slice(8, 10);\n\n // Determine century based on position 17 (digit for century)\n // 0-9 for people born 1900-1999, A for 2000+\n const centuryChar = cleaned[16];\n let year: number;\n\n if (/\\d/.test(centuryChar)) {\n year = 1900 + parseInt(yearPart, 10);\n } else {\n year = 2000 + parseInt(yearPart, 10);\n }\n\n const date = new Date(year, parseInt(month, 10) - 1, parseInt(day, 10));\n\n // Validate the date is real\n if (\n date.getFullYear() !== year ||\n date.getMonth() !== parseInt(month, 10) - 1 ||\n date.getDate() !== parseInt(day, 10)\n ) {\n return null;\n }\n\n return date;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export { DocumentType, FormatterFn, ValidationResult, ValidatorFn, cleanDigits, cleanDocument, mod10, mod11, padStart } from './core/index.cjs';
2
+ export { calculateNITCheckDigit, cleanCC, cleanNIT, formatCC, formatNIT, validateCC, validateCE, validateNIT, validateTI } from './locales/co.cjs';
3
+ export { cleanCNPJ, cleanCPF, formatCNPJ, formatCPF, validateCNPJ, validateCPF } from './locales/br.cjs';
4
+ export { calculateRUTCheckDigit, cleanRUN, cleanRUT, formatRUN, formatRUT, validateRUN, validateRUT } from './locales/cl.cjs';
5
+ export { calculateCUITCheckDigit, cleanCUIL, cleanCUIT, cleanDNI, formatCUIL, formatCUIT, formatDNI, validateCUIL, validateCUIT, validateDNI } from './locales/ar.cjs';
6
+ export { cleanCURP, cleanRFC, formatCURP, formatRFC, getCURPBirthDate, getCURPGender, validateCURP, validateRFC } from './locales/mx.cjs';
@@ -0,0 +1,6 @@
1
+ export { DocumentType, FormatterFn, ValidationResult, ValidatorFn, cleanDigits, cleanDocument, mod10, mod11, padStart } from './core/index.js';
2
+ export { calculateNITCheckDigit, cleanCC, cleanNIT, formatCC, formatNIT, validateCC, validateCE, validateNIT, validateTI } from './locales/co.js';
3
+ export { cleanCNPJ, cleanCPF, formatCNPJ, formatCPF, validateCNPJ, validateCPF } from './locales/br.js';
4
+ export { calculateRUTCheckDigit, cleanRUN, cleanRUT, formatRUN, formatRUT, validateRUN, validateRUT } from './locales/cl.js';
5
+ export { calculateCUITCheckDigit, cleanCUIL, cleanCUIT, cleanDNI, formatCUIL, formatCUIT, formatDNI, validateCUIL, validateCUIT, validateDNI } from './locales/ar.js';
6
+ export { cleanCURP, cleanRFC, formatCURP, formatRFC, getCURPBirthDate, getCURPGender, validateCURP, validateRFC } from './locales/mx.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ function a(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function o(e){return e.replace(/\D/g,"")}function T(e,t){return e.padStart(t,"0")}function R(e,t){let r=0;for(let n=0;n<e.length;n++)r+=parseInt(e[n],10)*t[n%t.length];return r%11}function D(e,t){let r=0;for(let i=0;i<e.length;i++){let n=parseInt(e[i],10)*t[i%t.length];n>9&&(n=Math.floor(n/10)+n%10),r+=n;}return r%10}var v=[3,7,13,17,19,23,29,37,41,43,47,53,59,67,71];function g(e){let t=o(e);if(t.length<8||t.length>15)throw new Error("NIT must be between 8 and 15 digits");let r=0,i=t.split("").reverse();for(let c=0;c<i.length;c++)r+=parseInt(i[c],10)*v[c];let n=r%11;return n===0?"0":n===1?"1":String(11-n)}function N(e){let t=o(e);if(t.length<9||t.length>16)return false;let r=t.slice(0,-1),i=t.slice(-1);try{return g(r)===i}catch{return false}}function P(e){let t=o(e);if(t.length<9)return e;let r=t.slice(0,-1),i=t.slice(-1);return `${r.replace(/\B(?=(\d{3})+(?!\d))/g,".")}-${i}`}function b(e){return o(e)}function F(e){let t=o(e);return t.length>=6&&t.length<=10}function $(e){return o(e).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function y(e){return o(e)}function S(e){let t=o(e);return t.length>=6&&t.length<=10}function k(e){let t=o(e);return t.length>=10&&t.length<=11}var _=[10,9,8,7,6,5,4,3,2],E=[11,10,9,8,7,6,5,4,3,2],A=[5,4,3,2,9,8,7,6,5,4,3,2],G=[6,5,4,3,2,9,8,7,6,5,4,3,2];function u(e,t){let r=0;for(let n=0;n<t.length;n++)r+=parseInt(e[n],10)*t[n];let i=r%11;return i<2?0:11-i}function H(e){let t=o(e);return t.length!==11||/^(\d)\1+$/.test(t)||u(t.slice(0,9),_)!==parseInt(t[9],10)?false:u(t.slice(0,10),E)===parseInt(t[10],10)}function J(e){let t=o(e).padStart(11,"0");return `${t.slice(0,3)}.${t.slice(3,6)}.${t.slice(6,9)}-${t.slice(9)}`}function L(e){return o(e)}function Z(e){let t=o(e);return t.length!==14||/^(\d)\1+$/.test(t)||u(t.slice(0,12),A)!==parseInt(t[12],10)?false:u(t.slice(0,13),G)===parseInt(t[13],10)}function M(e){let t=o(e).padStart(14,"0");return `${t.slice(0,2)}.${t.slice(2,5)}.${t.slice(5,8)}/${t.slice(8,12)}-${t.slice(12)}`}function W(e){return o(e)}var f=[2,3,4,5,6,7];function d(e){let r=o(e).split("").reverse(),i=0;for(let c=0;c<r.length;c++)i+=parseInt(r[c],10)*f[c%f.length];let n=11-i%11;return n===11?"0":n===10?"K":String(n)}function p(e){let t=a(e).toUpperCase();if(t.length<8||t.length>9)return false;let r=t.slice(0,-1),i=t.slice(-1);return /^\d+$/.test(r)?d(r)===i:false}function C(e){let t=a(e).toUpperCase();if(t.length<2)return e;let r=t.slice(0,-1),i=t.slice(-1);return `${r.replace(/\B(?=(\d{3})+(?!\d))/g,".")}-${i}`}function m(e){return a(e).toUpperCase()}var B=p,w=C,O=m;var V=[5,4,3,2,7,6,5,4,3,2];function I(e){let t=o(e);if(t.length!==10)throw new Error("CUIT body must be 10 digits");let r=0;for(let n=0;n<10;n++)r+=parseInt(t[n],10)*V[n];let i=11-r%11;return i===11?"0":i===10?"9":String(i)}function h(e){let t=o(e);if(t.length!==11)return false;let r=t.slice(0,2);if(!["20","23","24","27","30","33","34"].includes(r))return false;let n=t.slice(0,10),c=t.slice(-1);try{return I(n)===c}catch{return false}}function U(e){let t=o(e).padStart(11,"0");return `${t.slice(0,2)}-${t.slice(2,10)}-${t.slice(10)}`}function x(e){return o(e)}var K=h,Y=U,j=x;function z(e){let t=o(e);return t.length>=7&&t.length<=8}function Q(e){return o(e).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function X(e){return o(e)}var q=/^[A-ZÑ&]{4}\d{6}[A-Z0-9]{3}$/,tt=/^[A-ZÑ&]{3}\d{6}[A-Z0-9]{3}$/,et=/^[A-Z]{4}\d{6}[HM][A-Z]{5}[A-Z0-9]\d$/;function nt(e){let t=a(e).toUpperCase();return t.length!==12&&t.length!==13?false:t.length===13?q.test(t):tt.test(t)}function rt(e){return a(e).toUpperCase()}function it(e){return a(e).toUpperCase()}function ot(e){let t=a(e).toUpperCase();return t.length!==18||!et.test(t)?false:ct(t)}function ct(e){let t="0123456789ABCDEFGHIJKLMN\xD1OPQRSTUVWXYZ",r=0;for(let n=0;n<17;n++){let c=e[n],s=t.indexOf(c);if(s===-1)return false;r+=s*(18-n);}return (10-r%10)%10===parseInt(e[17],10)}function at(e){return a(e).toUpperCase()}function st(e){return a(e).toUpperCase()}function lt(e){let t=a(e).toUpperCase();if(t.length<11)return null;let r=t[10];return r==="H"?"M":r==="M"?"F":null}function ut(e){let t=a(e).toUpperCase();if(t.length<10)return null;let r=t.slice(4,6),i=t.slice(6,8),n=t.slice(8,10),c=t[16],s;/\d/.test(c)?s=1900+parseInt(r,10):s=2e3+parseInt(r,10);let l=new Date(s,parseInt(i,10)-1,parseInt(n,10));return l.getFullYear()!==s||l.getMonth()!==parseInt(i,10)-1||l.getDate()!==parseInt(n,10)?null:l}export{I as calculateCUITCheckDigit,g as calculateNITCheckDigit,d as calculateRUTCheckDigit,y as cleanCC,W as cleanCNPJ,L as cleanCPF,j as cleanCUIL,x as cleanCUIT,st as cleanCURP,X as cleanDNI,o as cleanDigits,a as cleanDocument,b as cleanNIT,it as cleanRFC,O as cleanRUN,m as cleanRUT,$ as formatCC,M as formatCNPJ,J as formatCPF,Y as formatCUIL,U as formatCUIT,at as formatCURP,Q as formatDNI,P as formatNIT,rt as formatRFC,w as formatRUN,C as formatRUT,ut as getCURPBirthDate,lt as getCURPGender,D as mod10,R as mod11,T as padStart,F as validateCC,S as validateCE,Z as validateCNPJ,H as validateCPF,K as validateCUIL,h as validateCUIT,ot as validateCURP,z as validateDNI,N as validateNIT,nt as validateRFC,B as validateRUN,p as validateRUT,k as validateTI};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/utils.ts","../src/locales/co.ts","../src/locales/br.ts","../src/locales/cl.ts","../src/locales/ar.ts","../src/locales/mx.ts"],"names":["cleanDocument","value","cleanDigits","padStart","length","mod11","digits","weights","sum","i","mod10","product","NIT_WEIGHTS","calculateNITCheckDigit","nit","cleaned","reversed","remainder","validateNIT","body","checkDigit","formatNIT","cleanNIT","validateCC","cc","formatCC","cleanCC","validateCE","ce","validateTI","ti","CPF_WEIGHTS_1","CPF_WEIGHTS_2","CNPJ_WEIGHTS_1","CNPJ_WEIGHTS_2","calcCheckDigit","validateCPF","cpf","formatCPF","cleanCPF","validateCNPJ","cnpj","formatCNPJ","cleanCNPJ","RUT_WEIGHTS","calculateRUTCheckDigit","rut","validateRUT","formatRUT","cleanRUT","validateRUN","formatRUN","cleanRUN","CUIT_WEIGHTS","calculateCUITCheckDigit","cuit","validateCUIT","type","formatCUIT","cleanCUIT","validateCUIL","formatCUIL","cleanCUIL","validateDNI","dni","formatDNI","cleanDNI","RFC_PATTERN_FISICA","RFC_PATTERN_MORAL","CURP_PATTERN","validateRFC","rfc","formatRFC","cleanRFC","validateCURP","curp","validateCURPCheckDigit","dictionary","char","formatCURP","cleanCURP","getCURPGender","genderChar","getCURPBirthDate","yearPart","month","day","centuryChar","year","date"],"mappings":"AAGO,SAASA,EAAcC,CAAAA,CAAuB,CACnD,OAAOA,CAAAA,CAAM,QAAQ,eAAA,CAAiB,EAAE,CAC1C,CAKO,SAASC,CAAAA,CAAYD,CAAAA,CAAuB,CACjD,OAAOA,EAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAeG,CAAAA,CAAwB,CAC9D,OAAOH,CAAAA,CAAM,QAAA,CAASG,CAAAA,CAAQ,GAAG,CACnC,CAKO,SAASC,CAAAA,CAAMC,EAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,CAAAA,CAAM,EACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,EAAO,MAAA,CAAQG,CAAAA,EAAAA,CACjCD,CAAAA,EAAO,QAAA,CAASF,EAAOG,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIF,EAAQE,CAAAA,CAAIF,CAAAA,CAAQ,MAAM,CAAA,CAG7D,OADkBC,CAAAA,CAAM,EAE1B,CAKO,SAASE,EAAMJ,CAAAA,CAAgBC,CAAAA,CAA2B,CAC/D,IAAIC,EAAM,CAAA,CACV,IAAA,IAAS,EAAI,CAAA,CAAG,CAAA,CAAIF,EAAO,MAAA,CAAQ,CAAA,EAAA,CAAK,CACtC,IAAIK,EAAU,QAAA,CAASL,CAAAA,CAAO,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIC,CAAAA,CAAQ,CAAA,CAAIA,CAAAA,CAAQ,MAAM,CAAA,CAC9DI,CAAAA,CAAU,CAAA,GACZA,CAAAA,CAAU,KAAK,KAAA,CAAMA,CAAAA,CAAU,EAAE,CAAA,CAAKA,EAAU,EAAA,CAAA,CAElDH,CAAAA,EAAOG,EACT,CACA,OAAOH,CAAAA,CAAM,EACf,CCxCA,IAAMI,EA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AAUf,CAAAA,CAAc2E,CAAI,CAAA,CAAE,WAAA,GACpC,GAAI5D,CAAAA,CAAQ,MAAA,CAAS,EAAA,CAAI,OAAO,IAAA,CAEhC,IAAMqE,CAAAA,CAAWrE,CAAAA,CAAQ,MAAM,CAAA,CAAG,CAAC,CAAA,CAC7BsE,CAAAA,CAAQtE,EAAQ,KAAA,CAAM,CAAA,CAAG,CAAC,CAAA,CAC1BuE,EAAMvE,CAAAA,CAAQ,KAAA,CAAM,CAAA,CAAG,EAAE,EAIzBwE,CAAAA,CAAcxE,CAAAA,CAAQ,EAAE,CAAA,CAC1ByE,EAEA,IAAA,CAAK,IAAA,CAAKD,CAAW,CAAA,CACvBC,EAAO,IAAA,CAAO,QAAA,CAASJ,EAAU,EAAE,CAAA,CAEnCI,EAAO,GAAA,CAAO,QAAA,CAASJ,CAAAA,CAAU,EAAE,EAGrC,IAAMK,CAAAA,CAAO,IAAI,IAAA,CAAKD,EAAM,QAAA,CAASH,CAAAA,CAAO,EAAE,CAAA,CAAI,EAAG,QAAA,CAASC,CAAAA,CAAK,EAAE,CAAC,EAGtE,OACEG,CAAAA,CAAK,WAAA,EAAY,GAAMD,GACvBC,CAAAA,CAAK,QAAA,EAAS,GAAM,QAAA,CAASJ,EAAO,EAAE,CAAA,CAAI,CAAA,EAC1CI,CAAAA,CAAK,SAAQ,GAAM,QAAA,CAASH,EAAK,EAAE,CAAA,CAE5B,KAGFG,CACT","file":"index.js","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * NIT verification weights (Colombian tax ID)\n * Algorithm: Multiply each digit by its weight, sum, mod 11\n */\nconst NIT_WEIGHTS = [3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71];\n\n/**\n * Calculate the NIT check digit\n * @param nit - The NIT without check digit (8-15 digits)\n * @returns The check digit (0-9)\n */\nexport function calculateNITCheckDigit(nit: string): string {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 8 || cleaned.length > 15) {\n throw new Error('NIT must be between 8 and 15 digits');\n }\n\n let sum = 0;\n const reversed = cleaned.split('').reverse();\n\n for (let i = 0; i < reversed.length; i++) {\n sum += parseInt(reversed[i], 10) * NIT_WEIGHTS[i];\n }\n\n const remainder = sum % 11;\n\n if (remainder === 0) return '0';\n if (remainder === 1) return '1';\n return String(11 - remainder);\n}\n\n/**\n * Validate a Colombian NIT\n * @param nit - The NIT to validate (with or without check digit)\n * @returns true if valid\n */\nexport function validateNIT(nit: string): boolean {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 9 || cleaned.length > 16) {\n return false;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateNITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a NIT for display\n * @param nit - The NIT to format\n * @returns Formatted NIT (e.g., \"900.123.456-7\")\n */\nexport function formatNIT(nit: string): string {\n const cleaned = cleanDigits(nit);\n\n if (cleaned.length < 9) {\n return nit;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Format with dots every 3 digits from right\n const formatted = body.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n\n return `${formatted}-${checkDigit}`;\n}\n\n/**\n * Clean a NIT (remove all formatting)\n */\nexport function cleanNIT(nit: string): string {\n return cleanDigits(nit);\n}\n\n/**\n * Validate a Colombian Cédula de Ciudadanía (CC)\n * @param cc - The CC number (6-10 digits)\n * @returns true if valid format\n */\nexport function validateCC(cc: string): boolean {\n const cleaned = cleanDigits(cc);\n return cleaned.length >= 6 && cleaned.length <= 10;\n}\n\n/**\n * Format a Cédula for display\n */\nexport function formatCC(cc: string): string {\n const cleaned = cleanDigits(cc);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a Cédula\n */\nexport function cleanCC(cc: string): string {\n return cleanDigits(cc);\n}\n\n/**\n * Validate a Cédula de Extranjería (CE)\n * @param ce - The CE number (6-10 digits)\n */\nexport function validateCE(ce: string): boolean {\n const cleaned = cleanDigits(ce);\n return cleaned.length >= 6 && cleaned.length <= 10;\n}\n\n/**\n * Validate a Tarjeta de Identidad (TI)\n * @param ti - The TI number (10-11 digits)\n */\nexport function validateTI(ti: string): boolean {\n const cleaned = cleanDigits(ti);\n return cleaned.length >= 10 && cleaned.length <= 11;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CPF weights for first check digit\n */\nconst CPF_WEIGHTS_1 = [10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CPF weights for second check digit\n */\nconst CPF_WEIGHTS_2 = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for first check digit\n */\nconst CNPJ_WEIGHTS_1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for second check digit\n */\nconst CNPJ_WEIGHTS_2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CPF/CNPJ check digit using mod 11\n */\nfunction calcCheckDigit(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < weights.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i];\n }\n const remainder = sum % 11;\n return remainder < 2 ? 0 : 11 - remainder;\n}\n\n/**\n * Validate a Brazilian CPF (Individual Tax ID)\n * @param cpf - The CPF to validate (11 digits)\n */\nexport function validateCPF(cpf: string): boolean {\n const cleaned = cleanDigits(cpf);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Check for known invalid CPFs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 9), CPF_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[9], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 10), CPF_WEIGHTS_2);\n return digit2 === parseInt(cleaned[10], 10);\n}\n\n/**\n * Format a CPF for display\n * @returns Formatted CPF (e.g., \"123.456.789-09\")\n */\nexport function formatCPF(cpf: string): string {\n const cleaned = cleanDigits(cpf).padStart(11, '0');\n return `${cleaned.slice(0, 3)}.${cleaned.slice(3, 6)}.${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;\n}\n\n/**\n * Clean a CPF\n */\nexport function cleanCPF(cpf: string): string {\n return cleanDigits(cpf);\n}\n\n/**\n * Validate a Brazilian CNPJ (Business Tax ID)\n * @param cnpj - The CNPJ to validate (14 digits)\n */\nexport function validateCNPJ(cnpj: string): boolean {\n const cleaned = cleanDigits(cnpj);\n\n if (cleaned.length !== 14) {\n return false;\n }\n\n // Check for known invalid CNPJs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 12), CNPJ_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[12], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 13), CNPJ_WEIGHTS_2);\n return digit2 === parseInt(cleaned[13], 10);\n}\n\n/**\n * Format a CNPJ for display\n * @returns Formatted CNPJ (e.g., \"12.345.678/0001-95\")\n */\nexport function formatCNPJ(cnpj: string): string {\n const cleaned = cleanDigits(cnpj).padStart(14, '0');\n return `${cleaned.slice(0, 2)}.${cleaned.slice(2, 5)}.${cleaned.slice(5, 8)}/${cleaned.slice(8, 12)}-${cleaned.slice(12)}`;\n}\n\n/**\n * Clean a CNPJ\n */\nexport function cleanCNPJ(cnpj: string): string {\n return cleanDigits(cnpj);\n}\n","import { cleanDocument, cleanDigits } from '../core/utils.js';\n\n/**\n * RUT/RUN validation weights\n */\nconst RUT_WEIGHTS = [2, 3, 4, 5, 6, 7];\n\n/**\n * Calculate RUT check digit\n * @param rut - The RUT body (without check digit)\n * @returns The check digit (0-9 or 'K')\n */\nexport function calculateRUTCheckDigit(rut: string): string {\n const cleaned = cleanDigits(rut);\n const reversed = cleaned.split('').reverse();\n\n let sum = 0;\n for (let i = 0; i < reversed.length; i++) {\n sum += parseInt(reversed[i], 10) * RUT_WEIGHTS[i % RUT_WEIGHTS.length];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return 'K';\n return String(remainder);\n}\n\n/**\n * Validate a Chilean RUT (Rol Único Tributario)\n * @param rut - The RUT to validate (e.g., \"12.345.678-5\" or \"12345678-K\")\n */\nexport function validateRUT(rut: string): boolean {\n const cleaned = cleanDocument(rut).toUpperCase();\n\n if (cleaned.length < 8 || cleaned.length > 9) {\n return false;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Body must be all digits\n if (!/^\\d+$/.test(body)) {\n return false;\n }\n\n return calculateRUTCheckDigit(body) === checkDigit;\n}\n\n/**\n * Format a RUT for display\n * @returns Formatted RUT (e.g., \"12.345.678-5\")\n */\nexport function formatRUT(rut: string): string {\n const cleaned = cleanDocument(rut).toUpperCase();\n\n if (cleaned.length < 2) {\n return rut;\n }\n\n const body = cleaned.slice(0, -1);\n const checkDigit = cleaned.slice(-1);\n\n // Format with dots every 3 digits from right\n const formatted = body.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n\n return `${formatted}-${checkDigit}`;\n}\n\n/**\n * Clean a RUT\n */\nexport function cleanRUT(rut: string): string {\n return cleanDocument(rut).toUpperCase();\n}\n\n/**\n * Validate a Chilean RUN (same algorithm as RUT)\n */\nexport const validateRUN = validateRUT;\nexport const formatRUN = formatRUT;\nexport const cleanRUN = cleanRUT;\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CUIT/CUIL weights\n */\nconst CUIT_WEIGHTS = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CUIT/CUIL check digit\n * @param cuit - The CUIT body (10 digits: type + DNI)\n * @returns The check digit (0-9)\n */\nexport function calculateCUITCheckDigit(cuit: string): string {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 10) {\n throw new Error('CUIT body must be 10 digits');\n }\n\n let sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += parseInt(cleaned[i], 10) * CUIT_WEIGHTS[i];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return '9'; // Special case for Argentina\n return String(remainder);\n}\n\n/**\n * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)\n * @param cuit - The CUIT to validate (e.g., \"20-12345678-9\")\n */\nexport function validateCUIT(cuit: string): boolean {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Valid type prefixes: 20, 23, 24, 27, 30, 33, 34\n const type = cleaned.slice(0, 2);\n const validTypes = ['20', '23', '24', '27', '30', '33', '34'];\n if (!validTypes.includes(type)) {\n return false;\n }\n\n const body = cleaned.slice(0, 10);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateCUITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a CUIT for display\n * @returns Formatted CUIT (e.g., \"20-12345678-9\")\n */\nexport function formatCUIT(cuit: string): string {\n const cleaned = cleanDigits(cuit).padStart(11, '0');\n return `${cleaned.slice(0, 2)}-${cleaned.slice(2, 10)}-${cleaned.slice(10)}`;\n}\n\n/**\n * Clean a CUIT\n */\nexport function cleanCUIT(cuit: string): string {\n return cleanDigits(cuit);\n}\n\n/**\n * CUIL validation (same algorithm as CUIT)\n */\nexport const validateCUIL = validateCUIT;\nexport const formatCUIL = formatCUIT;\nexport const cleanCUIL = cleanCUIT;\nexport const calculateCUILCheckDigit = calculateCUITCheckDigit;\n\n/**\n * Validate an Argentine DNI\n * @param dni - The DNI number (7-8 digits)\n */\nexport function validateDNI(dni: string): boolean {\n const cleaned = cleanDigits(dni);\n return cleaned.length >= 7 && cleaned.length <= 8;\n}\n\n/**\n * Format a DNI for display\n */\nexport function formatDNI(dni: string): string {\n const cleaned = cleanDigits(dni);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a DNI\n */\nexport function cleanDNI(dni: string): string {\n return cleanDigits(dni);\n}\n","import { cleanDocument } from '../core/utils.js';\n\n/**\n * Valid RFC patterns\n * - Persona física: 4 letters + 6 digits + 3 alphanumeric (homoclave)\n * - Persona moral: 3 letters + 6 digits + 3 alphanumeric (homoclave)\n */\nconst RFC_PATTERN_FISICA = /^[A-ZÑ&]{4}\\d{6}[A-Z0-9]{3}$/;\nconst RFC_PATTERN_MORAL = /^[A-ZÑ&]{3}\\d{6}[A-Z0-9]{3}$/;\n\n/**\n * CURP pattern\n * 18 characters: 4 letters + 6 digits + 6 letters + 2 alphanumeric\n */\nconst CURP_PATTERN = /^[A-Z]{4}\\d{6}[HM][A-Z]{5}[A-Z0-9]\\d$/;\n\n/**\n * Validate a Mexican RFC (Registro Federal de Contribuyentes)\n * @param rfc - The RFC to validate\n */\nexport function validateRFC(rfc: string): boolean {\n const cleaned = cleanDocument(rfc).toUpperCase();\n\n if (cleaned.length !== 12 && cleaned.length !== 13) {\n return false;\n }\n\n // 12 chars = Persona moral, 13 chars = Persona física\n if (cleaned.length === 13) {\n return RFC_PATTERN_FISICA.test(cleaned);\n }\n\n return RFC_PATTERN_MORAL.test(cleaned);\n}\n\n/**\n * Format an RFC for display (uppercase, no separators)\n */\nexport function formatRFC(rfc: string): string {\n return cleanDocument(rfc).toUpperCase();\n}\n\n/**\n * Clean an RFC\n */\nexport function cleanRFC(rfc: string): string {\n return cleanDocument(rfc).toUpperCase();\n}\n\n/**\n * Validate a Mexican CURP (Clave Única de Registro de Población)\n * @param curp - The CURP to validate (18 characters)\n */\nexport function validateCURP(curp: string): boolean {\n const cleaned = cleanDocument(curp).toUpperCase();\n\n if (cleaned.length !== 18) {\n return false;\n }\n\n if (!CURP_PATTERN.test(cleaned)) {\n return false;\n }\n\n // Validate check digit\n return validateCURPCheckDigit(cleaned);\n}\n\n/**\n * CURP check digit validation\n */\nfunction validateCURPCheckDigit(curp: string): boolean {\n const dictionary = '0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZ';\n let sum = 0;\n\n for (let i = 0; i < 17; i++) {\n const char = curp[i];\n const value = dictionary.indexOf(char);\n if (value === -1) return false;\n sum += value * (18 - i);\n }\n\n const checkDigit = (10 - (sum % 10)) % 10;\n return checkDigit === parseInt(curp[17], 10);\n}\n\n/**\n * Format a CURP for display\n */\nexport function formatCURP(curp: string): string {\n return cleanDocument(curp).toUpperCase();\n}\n\n/**\n * Clean a CURP\n */\nexport function cleanCURP(curp: string): string {\n return cleanDocument(curp).toUpperCase();\n}\n\n/**\n * Get the gender from a CURP\n * @returns 'M' for male, 'F' for female, or null if invalid\n */\nexport function getCURPGender(curp: string): 'M' | 'F' | null {\n const cleaned = cleanDocument(curp).toUpperCase();\n if (cleaned.length < 11) return null;\n\n const genderChar = cleaned[10];\n if (genderChar === 'H') return 'M';\n if (genderChar === 'M') return 'F';\n return null;\n}\n\n/**\n * Get the birth date from a CURP\n * @returns Date object or null if invalid\n */\nexport function getCURPBirthDate(curp: string): Date | null {\n const cleaned = cleanDocument(curp).toUpperCase();\n if (cleaned.length < 10) return null;\n\n const yearPart = cleaned.slice(4, 6);\n const month = cleaned.slice(6, 8);\n const day = cleaned.slice(8, 10);\n\n // Determine century based on position 17 (digit for century)\n // 0-9 for people born 1900-1999, A for 2000+\n const centuryChar = cleaned[16];\n let year: number;\n\n if (/\\d/.test(centuryChar)) {\n year = 1900 + parseInt(yearPart, 10);\n } else {\n year = 2000 + parseInt(yearPart, 10);\n }\n\n const date = new Date(year, parseInt(month, 10) - 1, parseInt(day, 10));\n\n // Validate the date is real\n if (\n date.getFullYear() !== year ||\n date.getMonth() !== parseInt(month, 10) - 1 ||\n date.getDate() !== parseInt(day, 10)\n ) {\n return null;\n }\n\n return date;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';function e(t){return t.replace(/\D/g,"")}var l=[5,4,3,2,7,6,5,4,3,2];function c(t){let n=e(t);if(n.length!==10)throw new Error("CUIT body must be 10 digits");let o=0;for(let r=0;r<10;r++)o+=parseInt(n[r],10)*l[r];let i=11-o%11;return i===11?"0":i===10?"9":String(i)}function a(t){let n=e(t);if(n.length!==11)return false;let o=n.slice(0,2);if(!["20","23","24","27","30","33","34"].includes(o))return false;let r=n.slice(0,10),s=n.slice(-1);try{return c(r)===s}catch{return false}}function u(t){let n=e(t).padStart(11,"0");return `${n.slice(0,2)}-${n.slice(2,10)}-${n.slice(10)}`}function g(t){return e(t)}var d=a,m=u,I=g,x=c;function h(t){let n=e(t);return n.length>=7&&n.length<=8}function C(t){return e(t).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function b(t){return e(t)}exports.calculateCUILCheckDigit=x;exports.calculateCUITCheckDigit=c;exports.cleanCUIL=I;exports.cleanCUIT=g;exports.cleanDNI=b;exports.formatCUIL=m;exports.formatCUIT=u;exports.formatDNI=C;exports.validateCUIL=d;exports.validateCUIT=a;exports.validateDNI=h;//# sourceMappingURL=ar.cjs.map
2
+ //# sourceMappingURL=ar.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/utils.ts","../../src/locales/ar.ts"],"names":["cleanDigits","value","CUIT_WEIGHTS","calculateCUITCheckDigit","cuit","cleaned","sum","i","remainder","validateCUIT","type","body","checkDigit","formatCUIT","cleanCUIT","validateCUIL","formatCUIL","cleanCUIL","calculateCUILCheckDigit","validateDNI","dni","formatDNI","cleanDNI"],"mappings":"aAUO,SAASA,CAAAA,CAAYC,CAAAA,CAAuB,CACjD,OAAOA,CAAAA,CAAM,QAAQ,KAAA,CAAO,EAAE,CAChC,CCPA,IAAMC,CAAAA,CAAe,CAAC,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAC,CAAA,CAO3C,SAASC,CAAAA,CAAwBC,CAAAA,CAAsB,CAC5D,IAAMC,CAAAA,CAAUL,CAAAA,CAAYI,CAAI,CAAA,CAEhC,GAAIC,EAAQ,MAAA,GAAW,EAAA,CACrB,MAAM,IAAI,KAAA,CAAM,6BAA6B,EAG/C,IAAIC,CAAAA,CAAM,CAAA,CACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAI,EAAA,CAAIA,CAAAA,EAAAA,CACtBD,CAAAA,EAAO,QAAA,CAASD,CAAAA,CAAQE,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIL,CAAAA,CAAaK,CAAC,CAAA,CAGlD,IAAMC,CAAAA,CAAY,GAAMF,CAAAA,CAAM,EAAA,CAE9B,OAAIE,CAAAA,GAAc,EAAA,CAAW,GAAA,CACzBA,IAAc,EAAA,CAAW,GAAA,CACtB,MAAA,CAAOA,CAAS,CACzB,CAMO,SAASC,CAAAA,CAAaL,CAAAA,CAAuB,CAClD,IAAMC,CAAAA,CAAUL,CAAAA,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Q,MAAA,EAAU,CAClD,CAKO,SAASgB,CAAAA,CAAUD,CAAAA,CAAqB,CAE7C,OADgBpB,CAAAA,CAAYoB,CAAG,EAChB,OAAA,CAAQ,uBAAA,CAAyB,GAAG,CACrD,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAqB,CAC5C,OAAOpB,CAAAA,CAAYoB,CAAG,CACxB","file":"ar.cjs","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CUIT/CUIL weights\n */\nconst CUIT_WEIGHTS = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CUIT/CUIL check digit\n * @param cuit - The CUIT body (10 digits: type + DNI)\n * @returns The check digit (0-9)\n */\nexport function calculateCUITCheckDigit(cuit: string): string {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 10) {\n throw new Error('CUIT body must be 10 digits');\n }\n\n let sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += parseInt(cleaned[i], 10) * CUIT_WEIGHTS[i];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return '9'; // Special case for Argentina\n return String(remainder);\n}\n\n/**\n * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)\n * @param cuit - The CUIT to validate (e.g., \"20-12345678-9\")\n */\nexport function validateCUIT(cuit: string): boolean {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Valid type prefixes: 20, 23, 24, 27, 30, 33, 34\n const type = cleaned.slice(0, 2);\n const validTypes = ['20', '23', '24', '27', '30', '33', '34'];\n if (!validTypes.includes(type)) {\n return false;\n }\n\n const body = cleaned.slice(0, 10);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateCUITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a CUIT for display\n * @returns Formatted CUIT (e.g., \"20-12345678-9\")\n */\nexport function formatCUIT(cuit: string): string {\n const cleaned = cleanDigits(cuit).padStart(11, '0');\n return `${cleaned.slice(0, 2)}-${cleaned.slice(2, 10)}-${cleaned.slice(10)}`;\n}\n\n/**\n * Clean a CUIT\n */\nexport function cleanCUIT(cuit: string): string {\n return cleanDigits(cuit);\n}\n\n/**\n * CUIL validation (same algorithm as CUIT)\n */\nexport const validateCUIL = validateCUIT;\nexport const formatCUIL = formatCUIT;\nexport const cleanCUIL = cleanCUIT;\nexport const calculateCUILCheckDigit = calculateCUITCheckDigit;\n\n/**\n * Validate an Argentine DNI\n * @param dni - The DNI number (7-8 digits)\n */\nexport function validateDNI(dni: string): boolean {\n const cleaned = cleanDigits(dni);\n return cleaned.length >= 7 && cleaned.length <= 8;\n}\n\n/**\n * Format a DNI for display\n */\nexport function formatDNI(dni: string): string {\n const cleaned = cleanDigits(dni);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a DNI\n */\nexport function cleanDNI(dni: string): string {\n return cleanDigits(dni);\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Calculate CUIT/CUIL check digit
3
+ * @param cuit - The CUIT body (10 digits: type + DNI)
4
+ * @returns The check digit (0-9)
5
+ */
6
+ declare function calculateCUITCheckDigit(cuit: string): string;
7
+ /**
8
+ * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)
9
+ * @param cuit - The CUIT to validate (e.g., "20-12345678-9")
10
+ */
11
+ declare function validateCUIT(cuit: string): boolean;
12
+ /**
13
+ * Format a CUIT for display
14
+ * @returns Formatted CUIT (e.g., "20-12345678-9")
15
+ */
16
+ declare function formatCUIT(cuit: string): string;
17
+ /**
18
+ * Clean a CUIT
19
+ */
20
+ declare function cleanCUIT(cuit: string): string;
21
+ /**
22
+ * CUIL validation (same algorithm as CUIT)
23
+ */
24
+ declare const validateCUIL: typeof validateCUIT;
25
+ declare const formatCUIL: typeof formatCUIT;
26
+ declare const cleanCUIL: typeof cleanCUIT;
27
+ declare const calculateCUILCheckDigit: typeof calculateCUITCheckDigit;
28
+ /**
29
+ * Validate an Argentine DNI
30
+ * @param dni - The DNI number (7-8 digits)
31
+ */
32
+ declare function validateDNI(dni: string): boolean;
33
+ /**
34
+ * Format a DNI for display
35
+ */
36
+ declare function formatDNI(dni: string): string;
37
+ /**
38
+ * Clean a DNI
39
+ */
40
+ declare function cleanDNI(dni: string): string;
41
+
42
+ export { calculateCUILCheckDigit, calculateCUITCheckDigit, cleanCUIL, cleanCUIT, cleanDNI, formatCUIL, formatCUIT, formatDNI, validateCUIL, validateCUIT, validateDNI };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Calculate CUIT/CUIL check digit
3
+ * @param cuit - The CUIT body (10 digits: type + DNI)
4
+ * @returns The check digit (0-9)
5
+ */
6
+ declare function calculateCUITCheckDigit(cuit: string): string;
7
+ /**
8
+ * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)
9
+ * @param cuit - The CUIT to validate (e.g., "20-12345678-9")
10
+ */
11
+ declare function validateCUIT(cuit: string): boolean;
12
+ /**
13
+ * Format a CUIT for display
14
+ * @returns Formatted CUIT (e.g., "20-12345678-9")
15
+ */
16
+ declare function formatCUIT(cuit: string): string;
17
+ /**
18
+ * Clean a CUIT
19
+ */
20
+ declare function cleanCUIT(cuit: string): string;
21
+ /**
22
+ * CUIL validation (same algorithm as CUIT)
23
+ */
24
+ declare const validateCUIL: typeof validateCUIT;
25
+ declare const formatCUIL: typeof formatCUIT;
26
+ declare const cleanCUIL: typeof cleanCUIT;
27
+ declare const calculateCUILCheckDigit: typeof calculateCUITCheckDigit;
28
+ /**
29
+ * Validate an Argentine DNI
30
+ * @param dni - The DNI number (7-8 digits)
31
+ */
32
+ declare function validateDNI(dni: string): boolean;
33
+ /**
34
+ * Format a DNI for display
35
+ */
36
+ declare function formatDNI(dni: string): string;
37
+ /**
38
+ * Clean a DNI
39
+ */
40
+ declare function cleanDNI(dni: string): string;
41
+
42
+ export { calculateCUILCheckDigit, calculateCUITCheckDigit, cleanCUIL, cleanCUIT, cleanDNI, formatCUIL, formatCUIT, formatDNI, validateCUIL, validateCUIT, validateDNI };
@@ -0,0 +1,2 @@
1
+ function e(t){return t.replace(/\D/g,"")}var l=[5,4,3,2,7,6,5,4,3,2];function c(t){let n=e(t);if(n.length!==10)throw new Error("CUIT body must be 10 digits");let o=0;for(let r=0;r<10;r++)o+=parseInt(n[r],10)*l[r];let i=11-o%11;return i===11?"0":i===10?"9":String(i)}function a(t){let n=e(t);if(n.length!==11)return false;let o=n.slice(0,2);if(!["20","23","24","27","30","33","34"].includes(o))return false;let r=n.slice(0,10),s=n.slice(-1);try{return c(r)===s}catch{return false}}function u(t){let n=e(t).padStart(11,"0");return `${n.slice(0,2)}-${n.slice(2,10)}-${n.slice(10)}`}function g(t){return e(t)}var d=a,m=u,I=g,x=c;function h(t){let n=e(t);return n.length>=7&&n.length<=8}function C(t){return e(t).replace(/\B(?=(\d{3})+(?!\d))/g,".")}function b(t){return e(t)}export{x as calculateCUILCheckDigit,c as calculateCUITCheckDigit,I as cleanCUIL,g as cleanCUIT,b as cleanDNI,m as formatCUIL,u as formatCUIT,C as formatDNI,d as validateCUIL,a as validateCUIT,h as validateDNI};//# sourceMappingURL=ar.js.map
2
+ //# sourceMappingURL=ar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/utils.ts","../../src/locales/ar.ts"],"names":["cleanDigits","value","CUIT_WEIGHTS","calculateCUITCheckDigit","cuit","cleaned","sum","i","remainder","validateCUIT","type","body","checkDigit","formatCUIT","cleanCUIT","validateCUIL","formatCUIL","cleanCUIL","calculateCUILCheckDigit","validateDNI","dni","formatDNI","cleanDNI"],"mappings":"AAUO,SAASA,CAAAA,CAAYC,CAAAA,CAAuB,CACjD,OAAOA,CAAAA,CAAM,QAAQ,KAAA,CAAO,EAAE,CAChC,CCPA,IAAMC,CAAAA,CAAe,CAAC,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAC,CAAA,CAO3C,SAASC,CAAAA,CAAwBC,CAAAA,CAAsB,CAC5D,IAAMC,CAAAA,CAAUL,CAAAA,CAAYI,CAAI,CAAA,CAEhC,GAAIC,EAAQ,MAAA,GAAW,EAAA,CACrB,MAAM,IAAI,KAAA,CAAM,6BAA6B,EAG/C,IAAIC,CAAAA,CAAM,CAAA,CACV,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAI,EAAA,CAAIA,CAAAA,EAAAA,CACtBD,CAAAA,EAAO,QAAA,CAASD,CAAAA,CAAQE,CAAC,CAAA,CAAG,EAAE,CAAA,CAAIL,CAAAA,CAAaK,CAAC,CAAA,CAGlD,IAAMC,CAAAA,CAAY,GAAMF,CAAAA,CAAM,EAAA,CAE9B,OAAIE,CAAAA,GAAc,EAAA,CAAW,GAAA,CACzBA,IAAc,EAAA,CAAW,GAAA,CACtB,MAAA,CAAOA,CAAS,CACzB,CAMO,SAASC,CAAAA,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AC/B,OAAOf,EAAQ,MAAA,EAAU,CAAA,EAAKA,CAAAA,CAAQ,MAAA,EAAU,CAClD,CAKO,SAASgB,CAAAA,CAAUD,CAAAA,CAAqB,CAE7C,OADgBpB,CAAAA,CAAYoB,CAAG,EAChB,OAAA,CAAQ,uBAAA,CAAyB,GAAG,CACrD,CAKO,SAASE,CAAAA,CAASF,CAAAA,CAAqB,CAC5C,OAAOpB,CAAAA,CAAYoB,CAAG,CACxB","file":"ar.js","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CUIT/CUIL weights\n */\nconst CUIT_WEIGHTS = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CUIT/CUIL check digit\n * @param cuit - The CUIT body (10 digits: type + DNI)\n * @returns The check digit (0-9)\n */\nexport function calculateCUITCheckDigit(cuit: string): string {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 10) {\n throw new Error('CUIT body must be 10 digits');\n }\n\n let sum = 0;\n for (let i = 0; i < 10; i++) {\n sum += parseInt(cleaned[i], 10) * CUIT_WEIGHTS[i];\n }\n\n const remainder = 11 - (sum % 11);\n\n if (remainder === 11) return '0';\n if (remainder === 10) return '9'; // Special case for Argentina\n return String(remainder);\n}\n\n/**\n * Validate an Argentine CUIT (Clave Única de Identificación Tributaria)\n * @param cuit - The CUIT to validate (e.g., \"20-12345678-9\")\n */\nexport function validateCUIT(cuit: string): boolean {\n const cleaned = cleanDigits(cuit);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Valid type prefixes: 20, 23, 24, 27, 30, 33, 34\n const type = cleaned.slice(0, 2);\n const validTypes = ['20', '23', '24', '27', '30', '33', '34'];\n if (!validTypes.includes(type)) {\n return false;\n }\n\n const body = cleaned.slice(0, 10);\n const checkDigit = cleaned.slice(-1);\n\n try {\n return calculateCUITCheckDigit(body) === checkDigit;\n } catch {\n return false;\n }\n}\n\n/**\n * Format a CUIT for display\n * @returns Formatted CUIT (e.g., \"20-12345678-9\")\n */\nexport function formatCUIT(cuit: string): string {\n const cleaned = cleanDigits(cuit).padStart(11, '0');\n return `${cleaned.slice(0, 2)}-${cleaned.slice(2, 10)}-${cleaned.slice(10)}`;\n}\n\n/**\n * Clean a CUIT\n */\nexport function cleanCUIT(cuit: string): string {\n return cleanDigits(cuit);\n}\n\n/**\n * CUIL validation (same algorithm as CUIT)\n */\nexport const validateCUIL = validateCUIT;\nexport const formatCUIL = formatCUIT;\nexport const cleanCUIL = cleanCUIT;\nexport const calculateCUILCheckDigit = calculateCUITCheckDigit;\n\n/**\n * Validate an Argentine DNI\n * @param dni - The DNI number (7-8 digits)\n */\nexport function validateDNI(dni: string): boolean {\n const cleaned = cleanDigits(dni);\n return cleaned.length >= 7 && cleaned.length <= 8;\n}\n\n/**\n * Format a DNI for display\n */\nexport function formatDNI(dni: string): string {\n const cleaned = cleanDigits(dni);\n return cleaned.replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n}\n\n/**\n * Clean a DNI\n */\nexport function cleanDNI(dni: string): string {\n return cleanDigits(dni);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';function e(n){return n.replace(/\D/g,"")}var o=[10,9,8,7,6,5,4,3,2],l=[11,10,9,8,7,6,5,4,3,2],a=[5,4,3,2,9,8,7,6,5,4,3,2],u=[6,5,4,3,2,9,8,7,6,5,4,3,2];function c(n,t){let r=0;for(let s=0;s<t.length;s++)r+=parseInt(n[s],10)*t[s];let i=r%11;return i<2?0:11-i}function p(n){let t=e(n);return t.length!==11||/^(\d)\1+$/.test(t)||c(t.slice(0,9),o)!==parseInt(t[9],10)?false:c(t.slice(0,10),l)===parseInt(t[10],10)}function d(n){let t=e(n).padStart(11,"0");return `${t.slice(0,3)}.${t.slice(3,6)}.${t.slice(6,9)}-${t.slice(9)}`}function m(n){return e(n)}function x(n){let t=e(n);return t.length!==14||/^(\d)\1+$/.test(t)||c(t.slice(0,12),a)!==parseInt(t[12],10)?false:c(t.slice(0,13),u)===parseInt(t[13],10)}function C(n){let t=e(n).padStart(14,"0");return `${t.slice(0,2)}.${t.slice(2,5)}.${t.slice(5,8)}/${t.slice(8,12)}-${t.slice(12)}`}function I(n){return e(n)}exports.cleanCNPJ=I;exports.cleanCPF=m;exports.formatCNPJ=C;exports.formatCPF=d;exports.validateCNPJ=x;exports.validateCPF=p;//# sourceMappingURL=br.cjs.map
2
+ //# sourceMappingURL=br.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/utils.ts","../../src/locales/br.ts"],"names":["cleanDigits","value","CPF_WEIGHTS_1","CPF_WEIGHTS_2","CNPJ_WEIGHTS_1","CNPJ_WEIGHTS_2","calcCheckDigit","digits","weights","sum","i","remainder","validateCPF","cpf","cleaned","formatCPF","cleanCPF","validateCNPJ","cnpj","formatCNPJ","cleanCNPJ"],"mappings":"aAUO,SAASA,CAAAA,CAAYC,CAAAA,CAAuB,CACjD,OAAOA,EAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CC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AAsB,CAC/C,IAAMJ,CAAAA,CAAUd,CAAAA,CAAYkB,CAAI,EAAE,QAAA,CAAS,EAAA,CAAI,GAAG,CAAA,CAClD,OAAO,CAAA,EAAGJ,CAAAA,CAAQ,KAAA,CAAM,CAAA,CAAG,CAAC,CAAC,CAAA,CAAA,EAAIA,CAAAA,CAAQ,MAAM,CAAA,CAAG,CAAC,CAAC,CAAA,CAAA,EAAIA,EAAQ,KAAA,CAAM,CAAA,CAAG,CAAC,CAAC,IAAIA,CAAAA,CAAQ,KAAA,CAAM,CAAA,CAAG,EAAE,CAAC,CAAA,CAAA,EAAIA,CAAAA,CAAQ,KAAA,CAAM,EAAE,CAAC,CAAA,CAC1H,CAKO,SAASM,EAAUF,CAAAA,CAAsB,CAC9C,OAAOlB,CAAAA,CAAYkB,CAAI,CACzB","file":"br.cjs","sourcesContent":["/**\n * Remove all non-alphanumeric characters\n */\nexport function cleanDocument(value: string): string {\n return value.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Remove all non-digit characters\n */\nexport function cleanDigits(value: string): string {\n return value.replace(/\\D/g, '');\n}\n\n/**\n * Pad a string with leading zeros\n */\nexport function padStart(value: string, length: number): string {\n return value.padStart(length, '0');\n}\n\n/**\n * Calculate modulo 11 check digit (common algorithm)\n */\nexport function mod11(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i % weights.length];\n }\n const remainder = sum % 11;\n return remainder;\n}\n\n/**\n * Calculate modulo 10 check digit (Luhn-like algorithms)\n */\nexport function mod10(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < digits.length; i++) {\n let product = parseInt(digits[i], 10) * weights[i % weights.length];\n if (product > 9) {\n product = Math.floor(product / 10) + (product % 10);\n }\n sum += product;\n }\n return sum % 10;\n}\n","import { cleanDigits } from '../core/utils.js';\n\n/**\n * CPF weights for first check digit\n */\nconst CPF_WEIGHTS_1 = [10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CPF weights for second check digit\n */\nconst CPF_WEIGHTS_2 = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for first check digit\n */\nconst CNPJ_WEIGHTS_1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * CNPJ weights for second check digit\n */\nconst CNPJ_WEIGHTS_2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * Calculate CPF/CNPJ check digit using mod 11\n */\nfunction calcCheckDigit(digits: string, weights: number[]): number {\n let sum = 0;\n for (let i = 0; i < weights.length; i++) {\n sum += parseInt(digits[i], 10) * weights[i];\n }\n const remainder = sum % 11;\n return remainder < 2 ? 0 : 11 - remainder;\n}\n\n/**\n * Validate a Brazilian CPF (Individual Tax ID)\n * @param cpf - The CPF to validate (11 digits)\n */\nexport function validateCPF(cpf: string): boolean {\n const cleaned = cleanDigits(cpf);\n\n if (cleaned.length !== 11) {\n return false;\n }\n\n // Check for known invalid CPFs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 9), CPF_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[9], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 10), CPF_WEIGHTS_2);\n return digit2 === parseInt(cleaned[10], 10);\n}\n\n/**\n * Format a CPF for display\n * @returns Formatted CPF (e.g., \"123.456.789-09\")\n */\nexport function formatCPF(cpf: string): string {\n const cleaned = cleanDigits(cpf).padStart(11, '0');\n return `${cleaned.slice(0, 3)}.${cleaned.slice(3, 6)}.${cleaned.slice(6, 9)}-${cleaned.slice(9)}`;\n}\n\n/**\n * Clean a CPF\n */\nexport function cleanCPF(cpf: string): string {\n return cleanDigits(cpf);\n}\n\n/**\n * Validate a Brazilian CNPJ (Business Tax ID)\n * @param cnpj - The CNPJ to validate (14 digits)\n */\nexport function validateCNPJ(cnpj: string): boolean {\n const cleaned = cleanDigits(cnpj);\n\n if (cleaned.length !== 14) {\n return false;\n }\n\n // Check for known invalid CNPJs (all same digits)\n if (/^(\\d)\\1+$/.test(cleaned)) {\n return false;\n }\n\n // Calculate first check digit\n const digit1 = calcCheckDigit(cleaned.slice(0, 12), CNPJ_WEIGHTS_1);\n if (digit1 !== parseInt(cleaned[12], 10)) {\n return false;\n }\n\n // Calculate second check digit\n const digit2 = calcCheckDigit(cleaned.slice(0, 13), CNPJ_WEIGHTS_2);\n return digit2 === parseInt(cleaned[13], 10);\n}\n\n/**\n * Format a CNPJ for display\n * @returns Formatted CNPJ (e.g., \"12.345.678/0001-95\")\n */\nexport function formatCNPJ(cnpj: string): string {\n const cleaned = cleanDigits(cnpj).padStart(14, '0');\n return `${cleaned.slice(0, 2)}.${cleaned.slice(2, 5)}.${cleaned.slice(5, 8)}/${cleaned.slice(8, 12)}-${cleaned.slice(12)}`;\n}\n\n/**\n * Clean a CNPJ\n */\nexport function cleanCNPJ(cnpj: string): string {\n return cleanDigits(cnpj);\n}\n"]}