From f54599c8fbd43b1febb2cbc18190107417fbdd5e Mon Sep 17 00:00:00 2001 From: ticmaisdev <128381407+ticmaisdev@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:56:22 -0400 Subject: [PATCH] refactor: make brazilian postal code separator optional (#2493) --- src/lib/isPostalCode.js | 2 +- test/validators.test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index 103656205..cadf39346 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -14,7 +14,7 @@ const patterns = { BA: /^([7-8]\d{4}$)/, BE: fourDigit, BG: fourDigit, - BR: /^\d{5}-\d{3}$/, + BR: /^\d{5}-?\d{3}$/, BY: /^2[1-4]\d{4}$/, CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, CH: fourDigit, diff --git a/test/validators.test.js b/test/validators.test.js index adf5d2cfe..af170bf69 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -12742,6 +12742,9 @@ describe('Validators', () => { '39100-000', '22040-020', '39400-152', + '39100000', + '22040020', + '39400152', ], invalid: [ '79800A12',