Skip to content
This repository has been 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/js/validator/zipCode.js
Expand Up @@ -5,6 +5,7 @@
country: 'Please enter a valid postal code in %s',
countries: {
AT: 'Austria',
BE: 'Belgium',
BR: 'Brazil',
CA: 'Canada',
CH: 'Switzerland',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down