Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Belgium Zip Code validation #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Belgium Zip Code validation
srigaux authored Apr 26, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 1cbedae5b1cd29d3ee1acd8104c82d3f4b83980e
7 changes: 6 additions & 1 deletion src/js/validator/zipCode.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
country: 'Please enter a valid postal code in %s',
countries: {
AT: 'Austria',
BE: 'Belgium',
BR: 'Brazil',
CA: 'Canada',
CH: 'Switzerland',
@@ -33,7 +34,7 @@
country: 'country'
},

COUNTRY_CODES: [ 'AT', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'FR', 'GB', 'IE', 'IT', 'MA', 'NL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'US'],
COUNTRY_CODES: [ 'AT', 'BE', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'FR', 'GB', 'IE', 'IT', 'MA', 'NL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'US'],

/**
* Return true if and only if the input value is a valid country zip code
@@ -81,6 +82,10 @@
case 'AT':
isValid = /^([1-9]{1})(\d{3})$/.test(value);
break;
// https://en.wikipedia.org/wiki/List_of_postal_codes_in_Belgium
case 'BE':
isValid = /^([1-9]{1})(\d{3})$/.test(value);
break;

case 'BR':
isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);