From 78f36c088d16a890e326bf9f5414eb9d7955e1e8 Mon Sep 17 00:00:00 2001 From: Alexandra Vilcan Date: Tue, 24 Oct 2017 15:37:06 +0300 Subject: [PATCH] isPostalCode validation for AU locale was checking for six digits, but Australian Postal Codes are 4 digits. Added a unit test for the use case also --- src/lib/isPostalCode.js | 2 +- test/validators.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js index af906eff6..5b0b5cbeb 100644 --- a/src/lib/isPostalCode.js +++ b/src/lib/isPostalCode.js @@ -8,7 +8,7 @@ const sixDigit = /^\d{6}$/; const patterns = { AT: fourDigit, - AU: sixDigit, + AU: fourDigit, BE: fourDigit, CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, CH: fourDigit, diff --git a/test/validators.js b/test/validators.js index c4e8bb959..593c3b43d 100644 --- a/test/validators.js +++ b/test/validators.js @@ -4932,6 +4932,16 @@ describe('Validators', function () { it('should validate postal code', function () { const fixtures = [ + { + locale: 'AU', + valid: [ + '4000', + '2620', + '3000', + '2017', + '0800', + ], + }, { locale: 'CA', valid: [