validator-tax-id 1.0.0 → 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 [Angel Blanco]
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 CHANGED
@@ -40,18 +40,50 @@ const isNieValid = validateIdentification("es", "X1234567L"); // true
40
40
  // 🇵🇹 Portugal (PT)
41
41
  // Validates NIF (9 digits with checksum)
42
42
  const isNifValid = validateIdentification("pt", "232013969"); // true
43
+
44
+ // 🇫🇷 France (FR)
45
+ // Validates SIREN (9 digits) or SIRET (14 digits)
46
+ const isSirenValid = validateIdentification("fr", "443061841"); // true
43
47
  ```
44
48
 
45
49
  ## API Reference
46
50
 
47
51
  ### `validateIdentification(country, value)`
48
52
 
49
- - **country**: `CountryCode` ('es' | 'pt') - The ISO code of the country.
53
+ - **country**: `CountryCode` ('es' | 'pt' | 'fr') - The ISO code of the country.
50
54
  - **value**: `string` | `any` - The document string to validate.
51
55
  - **Returns**: `boolean` (`true` if valid, `false` otherwise).
52
56
 
53
57
  _Note: The validator sanitizes the input automatically (removes spaces, hyphens, and is case-insensitive)._
54
58
 
59
+ ## SUPPORTED COUNTRIES
60
+
61
+ | Country | Code | Documents Supported | Algorithm |
62
+ | -------- | ---- | ------------------- | -------------- |
63
+ | Spain | es | DNI, NIE | Modulo 23 |
64
+ | Portugal | pt | NIF (Personal) | Modulo 11 |
65
+ | France | fr | SIREN, SIRET | Luhn Algorithm |
66
+
67
+ # Changelog
68
+
69
+ All notable changes to this project will be documented in this file.
70
+
71
+ ## [1.1.0] - 2026-01-17
72
+
73
+ ### Added 🚀
74
+
75
+ - **France (FR)** support added.
76
+ - Validation for **SIREN** (9 digits) and **SIRET** (14 digits) using Luhn algorithm.
77
+
78
+ ## [1.0.0] - 2026-01-17
79
+
80
+ ### Added
81
+
82
+ - Initial release.
83
+ - **Spain (ES)** support: DNI and NIE validation (Modulo 23).
84
+ - **Portugal (PT)** support: NIF validation (Modulo 11).
85
+ - Core logic and TypeScript types.
86
+
55
87
  ## License
56
88
 
57
89
  MIT
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},g=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!y.call(e,r)&&r!==o&&s(e,r,{get:()=>t[r],enumerable:!(n=d(t,r))||n.enumerable});return e};var x=e=>g(s({},"__esModule",{value:!0}),e);var T={};m(T,{validateIdentification:()=>I});module.exports=x(T);var C="TRWAGMYFPDXBNJZSQVHLCKE";var l=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let n=t.slice(0,-1),r=t.slice(-1);n=n.replace("X","0").replace("Y","1").replace("Z","2");let a=parseInt(n,10);return C[a%23]===r};var i=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((a,c,p)=>{let f=9-p;return a+parseInt(c,10)*f},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var v={es:l,pt:i};var I=(e,t)=>{let o=v[e];return o?o(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};0&&(module.exports={validateIdentification});
1
+ "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},x=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!m.call(e,r)&&r!==o&&s(e,r,{get:()=>t[r],enumerable:!(n=u(t,r))||n.enumerable});return e};var b=e=>x(s({},"__esModule",{value:!0}),e);var T={};g(T,{validateIdentification:()=>I});module.exports=b(T);var v="TRWAGMYFPDXBNJZSQVHLCKE";var l=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let n=t.slice(0,-1),r=t.slice(-1);n=n.replace("X","0").replace("Y","1").replace("Z","2");let a=parseInt(n,10);return v[a%23]===r};var i=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^\d{9}$/.test(t)&&!/^\d{14}$/.test(t))return!1;let o=0,n=!1;for(let r=t.length-1;r>=0;r--){let a=parseInt(t.charAt(r),10);n&&(a*=2,a>9&&(a-=9)),o+=a,n=!n}return o%10===0};var c=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((a,f,p)=>{let d=9-p;return a+parseInt(f,10)*d},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var C={es:l,pt:c,fr:i};var I=(e,t)=>{let o=C[e];return o?o(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};0&&(module.exports={validateIdentification});
2
2
  /**
3
3
  * Validate Spanish DNI/NIE numbers.
4
4
  * @param value - The DNI or NIE number to validate
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare const validators: {
2
2
  es: (value: any) => boolean;
3
3
  pt: (value: any) => boolean;
4
+ fr: (value: any) => boolean;
4
5
  };
5
6
  type CountryCode = keyof typeof validators;
6
7
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare const validators: {
2
2
  es: (value: any) => boolean;
3
3
  pt: (value: any) => boolean;
4
+ fr: (value: any) => boolean;
4
5
  };
5
6
  type CountryCode = keyof typeof validators;
6
7
  /**
@@ -1,4 +1,4 @@
1
- "use strict";var TaxIdValidator=(()=>{var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},g=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!y.call(e,r)&&r!==o&&s(e,r,{get:()=>t[r],enumerable:!(n=d(t,r))||n.enumerable});return e};var x=e=>g(s({},"__esModule",{value:!0}),e);var T={};m(T,{validateIdentification:()=>I});var C="TRWAGMYFPDXBNJZSQVHLCKE";var l=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let n=t.slice(0,-1),r=t.slice(-1);n=n.replace("X","0").replace("Y","1").replace("Z","2");let a=parseInt(n,10);return C[a%23]===r};var i=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((a,c,p)=>{let f=9-p;return a+parseInt(c,10)*f},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var v={es:l,pt:i};var I=(e,t)=>{let o=v[e];return o?o(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};return x(T);})();
1
+ "use strict";var TaxIdValidator=(()=>{var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},x=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of y(t))!m.call(e,r)&&r!==o&&s(e,r,{get:()=>t[r],enumerable:!(n=u(t,r))||n.enumerable});return e};var b=e=>x(s({},"__esModule",{value:!0}),e);var T={};g(T,{validateIdentification:()=>I});var v="TRWAGMYFPDXBNJZSQVHLCKE";var l=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let n=t.slice(0,-1),r=t.slice(-1);n=n.replace("X","0").replace("Y","1").replace("Z","2");let a=parseInt(n,10);return v[a%23]===r};var i=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^\d{9}$/.test(t)&&!/^\d{14}$/.test(t))return!1;let o=0,n=!1;for(let r=t.length-1;r>=0;r--){let a=parseInt(t.charAt(r),10);n&&(a*=2,a>9&&(a-=9)),o+=a,n=!n}return o%10===0};var c=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((a,f,p)=>{let d=9-p;return a+parseInt(f,10)*d},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var C={es:l,pt:c,fr:i};var I=(e,t)=>{let o=C[e];return o?o(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};return b(T);})();
2
2
  /**
3
3
  * Validate Spanish DNI/NIE numbers.
4
4
  * @param value - The DNI or NIE number to validate
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var f="TRWAGMYFPDXBNJZSQVHLCKE";var s=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let n=t.slice(0,-1),r=t.slice(-1);n=n.replace("X","0").replace("Y","1").replace("Z","2");let a=parseInt(n,10);return f[a%23]===r};var l=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((a,i,c)=>{let p=9-c;return a+parseInt(i,10)*p},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var d={es:s,pt:l};var x=(e,t)=>{let o=d[e];return o?o(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};export{x as validateIdentification};
1
+ var d="TRWAGMYFPDXBNJZSQVHLCKE";var s=e=>{if(typeof e!="string")return!1;let t=e.toUpperCase().replace(/\s|-/g,"");if(!/^([0-9]{8}|[XYZ][0-9]{7})[A-Z]$/.test(t))return!1;let o=t.slice(0,-1),r=t.slice(-1);o=o.replace("X","0").replace("Y","1").replace("Z","2");let n=parseInt(o,10);return d[n%23]===r};var l=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^\d{9}$/.test(t)&&!/^\d{14}$/.test(t))return!1;let a=0,o=!1;for(let r=t.length-1;r>=0;r--){let n=parseInt(t.charAt(r),10);o&&(n*=2,n>9&&(n-=9)),a+=n,o=!o}return a%10===0};var i=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s|-/g,"");if(!/^[0-9]{9}$/.test(t))return!1;let r=11-t.slice(0,8).split("").reduce((n,c,f)=>{let p=9-f;return n+parseInt(c,10)*p},0)%11;return r>=10&&(r=0),r===parseInt(t[8],10)};var u={es:s,pt:i,fr:l};var C=(e,t)=>{let a=u[e];return a?a(t):(console.warn(`[TaxIDValidator] Country '${e}' not supported yet.`),!1)};export{C as validateIdentification};
2
2
  /**
3
3
  * Validate Spanish DNI/NIE numbers.
4
4
  * @param value - The DNI or NIE number to validate
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "validator-tax-id",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
+ "license": "MIT",
8
9
  "exports": {
9
10
  ".": {
10
11
  "types": "./dist/index.d.ts",