From d18a8b8caa54f645aab269b01a36faaceb76a802 Mon Sep 17 00:00:00 2001 From: Aditya Raval Date: Sun, 13 Oct 2019 15:44:03 +0530 Subject: [PATCH] fix(isPostalCode): postal code validation fix for locale IN (#1152) * postal code validation fix for locale IN * regex updated --- src/lib/isPostalCode.js | 2 +- test/validators.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index 296d5905f..4176d5a21 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -30,7 +30,7 @@ const patterns = { ID: fiveDigit, IE: /^[A-z]\d[\d|w]\s\w{4}$/i, IL: fiveDigit, - IN: sixDigit, + IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, IS: threeDigit, IT: fiveDigit, JP: /^\d{3}\-\d{4}$/, diff --git a/test/validators.js b/test/validators.js index 09715fb3e..0efbd4adf 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6743,6 +6743,29 @@ describe('Validators', () => { 'A65T F12', ], }, + { + locale: 'IN', + valid: [ + '364240', + '360005', + ], + invalid: [ + '123', + '012345', + '011111', + '101123', + '291123', + '351123', + '541123', + '551123', + '651123', + '661123', + '861123', + '871123', + '881123', + '891123', + ], + }, { locale: 'BG', valid: [