diff --git a/src/lib/isIdentityCard.js b/src/lib/isIdentityCard.js index 7e20064e1..206bb3740 100644 --- a/src/lib/isIdentityCard.js +++ b/src/lib/isIdentityCard.js @@ -72,7 +72,7 @@ const validators = { return false; } - if (!str.match(/^\d{6}[\-A\+]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) { + if (!str.match(/^\d{6}[\-+A-FU-Y]\d{3}[0-9ABCDEFHJKLMNPRSTUVWXY]{1}$/)) { return false; } diff --git a/src/lib/isTaxID.js b/src/lib/isTaxID.js index 2c293f71a..67b53f305 100644 --- a/src/lib/isTaxID.js +++ b/src/lib/isTaxID.js @@ -501,12 +501,17 @@ function etEeCheck(tin) { function fiFiCheck(tin) { // Extract year and add century let full_year = tin.slice(4, 6); - const century_symbol = tin.slice(6, 7); + const century_symbol = tin.slice(6, 7).toUpperCase(); switch (century_symbol) { case '+': full_year = `18${full_year}`; break; case '-': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': full_year = `19${full_year}`; break; default: @@ -1198,7 +1203,7 @@ const taxIdFormat = { 'es-AR': /(20|23|24|27|30|33|34)[0-9]{8}[0-9]/, 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i, 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/, - 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i, + 'fi-FI': /^\d{6}[-+A-FU-Y]\d{3}[0-9A-FHJ-NPR-Y]$/i, 'fr-BE': /^\d{11}$/, 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/, // Conforms both to official spec and provided example 'fr-LU': /^\d{13}$/, diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..cdb36603e 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -6834,11 +6834,14 @@ describe('Validators', () => { '131052A308T', // People born in 2000s '131052+308T', // People born in 1800s '131052-313Y', + '010594Y9021', // New century signs since 2023 + '020502E902X', ], invalid: [ '131052308T', '131052-308T ', '131052-308A', + '131052G308T', ], }, { @@ -13982,13 +13985,17 @@ describe('Validators', () => { valid: [ '131052-308T', '131002+308W', - '131019A3089'], + '131019A3089', + '010594Y9021', + '020502E902X', + '290200A1239'], invalid: [ '131052308T', '131052-308TT', '131052S308T', '13 1052-308/T', - '290219A1111'], + '290219A1111', + '290200Y1239'], }); test({ validator: 'isTaxID',