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 +21 -0
- package/README.md +33 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.global.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -1
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
|
|
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
package/dist/index.d.ts
CHANGED
package/dist/index.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var TaxIdValidator=(()=>{var s=Object.defineProperty;var
|
|
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
|
|
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.
|
|
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",
|