Skip to content

Commit b62c1b7

Browse files
authored
feat(location): en_CA postcodes by state (#3057)
1 parent cc7715b commit b62c1b7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/locales/en_CA/location/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { LocationDefinition } from '../../..';
66
import city_name from './city_name';
77
import city_pattern from './city_pattern';
88
import postcode from './postcode';
9+
import postcode_by_state from './postcode_by_state';
910
import state from './state';
1011
import state_abbr from './state_abbr';
1112
import street_pattern from './street_pattern';
@@ -14,6 +15,7 @@ const location: LocationDefinition = {
1415
city_name,
1516
city_pattern,
1617
postcode,
18+
postcode_by_state,
1719
state,
1820
state_abbr,
1921
street_pattern,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// https://en.wikipedia.org/wiki/Postal_codes_in_Canada
2+
// The basic format is A1A 1A1
3+
// First letter is province/territory-specific
4+
// Other letters do not allow D, F, I, O, Q, U
5+
const suffix = '[0-9][ABCEGHJ-NPRSTVW-Z] [0-9][ABCEGHJ-NPRSTVW-Z][0-9]';
6+
7+
export default {
8+
AB: `{{helpers.fromRegExp(T${suffix})}}`, // Alberta
9+
BC: `{{helpers.fromRegExp(V${suffix})}}`, // British Columbia
10+
MB: `{{helpers.fromRegExp(R${suffix})}}`, // Manitoba
11+
NB: `{{helpers.fromRegExp(E${suffix})}}`, // New Brunswick
12+
NL: `{{helpers.fromRegExp(A${suffix})}}`, // Newfoundland and Labrador
13+
NS: `{{helpers.fromRegExp(B${suffix})}}`, // Nova Scotia
14+
NT: `{{helpers.fromRegExp(X${suffix})}}`, // Northwest Territories
15+
NU: `{{helpers.fromRegExp(X${suffix})}}`, // Nunavut
16+
ON: `{{helpers.fromRegExp([KLMNP]${suffix})}}`, // Ontario
17+
PE: `{{helpers.fromRegExp(C${suffix})}}`, // Prince Edward Island
18+
QC: `{{helpers.fromRegExp([GHJ]${suffix})}}`, // Quebec
19+
SK: `{{helpers.fromRegExp(S${suffix})}}`, // Saskatchewan
20+
YT: `{{helpers.fromRegExp(Y${suffix})}}`, // Yukon
21+
};

0 commit comments

Comments
 (0)