-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch tin-validator@2.1.0 for the project I'm working on.
I've found that the validation formats for legal entities do not match actual formats used in the EU for some of the countries.
I've identified this on my own case (CZ), and used the following document to identify any other mismatches:
https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:52016XC1223(02)
and cross-referenced with
https://www.societegenerale.lu/fileadmin/user_upload/SGBT/PDF/Compliance/CRS_2018/20191031_TIN_Leaflet_EN.pdf
Both docs are older, but since the formats do not change frequently, I assume it's still the same, since I've not found any newer info.
Here is the diff that solved my problem:
diff --git a/node_modules/tin-validator/src/validators/validators-by-country.js b/node_modules/tin-validator/src/validators/validators-by-country.js
index ea37ea1..5991038 100644
--- a/node_modules/tin-validator/src/validators/validators-by-country.js
+++ b/node_modules/tin-validator/src/validators/validators-by-country.js
@@ -34,17 +34,17 @@ module.exports = {
},
// Czechia
CZ: {
- formats: [/^\d{9}$/, /^\d{10}$/],
+ formats: [/^(CZ)?\d{8}$/],
validateInternally: true
},
// Germany
DE: {
- formats: [/^\d{11}$/],
+ formats: [/.+/],
validateInternally: true
},
// Denmark
DK: {
- formats: [/^\d{8}$/],
+ formats: [/^(DK)?\d{8}$/],
validateInternally: true
},
// Estonia
@@ -54,7 +54,7 @@ module.exports = {
},
// Spain
ES: {
- formats: [/^[A-Z]\d{8}$/],
+ formats: [/^[ABCDEFGHJNPQRSUVW]\d{7}[A-Z0-9]$/],
validateInternally: true
},
// Finland
@@ -135,7 +135,7 @@ module.exports = {
},
// Latvia
LV: {
- formats: [/^\d{11}$/],
+ formats: [/^(LV)?\d{11}$/],
validateInternally: true
},
// Saint Martin
@@ -180,12 +180,12 @@ module.exports = {
},
// Romania
RO: {
- formats: [/^\d{13}$/],
+ formats: [/^\d{2,10}$/],
validateInternally: true
},
// Sweden
SE: {
- formats: [/^\d{10}$/],
+ formats: [/^(?:\d{10}|16\d{10})$/],
validateInternally: true
},
// SloveniaThis issue body was partially generated by patch-package.