From c4d0d6fdd0ac28f612c0853598338de33fe87c3b Mon Sep 17 00:00:00 2001 From: Matt Mayer Date: Fri, 16 Aug 2024 05:24:30 +0700 Subject: [PATCH 1/3] feat: ca postcodes by state --- src/locales/en_CA/location/index.ts | 2 ++ .../en_CA/location/postcode_by_state.ts | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/locales/en_CA/location/postcode_by_state.ts diff --git a/src/locales/en_CA/location/index.ts b/src/locales/en_CA/location/index.ts index 9f6d2f7dc65..8103ffb4e93 100644 --- a/src/locales/en_CA/location/index.ts +++ b/src/locales/en_CA/location/index.ts @@ -6,6 +6,7 @@ import type { LocationDefinition } from '../../..'; import city_name from './city_name'; import city_pattern from './city_pattern'; import postcode from './postcode'; +import postcode_by_state from './postcode_by_state'; import state from './state'; import state_abbr from './state_abbr'; import street_pattern from './street_pattern'; @@ -14,6 +15,7 @@ const location: LocationDefinition = { city_name, city_pattern, postcode, + postcode_by_state, state, state_abbr, street_pattern, diff --git a/src/locales/en_CA/location/postcode_by_state.ts b/src/locales/en_CA/location/postcode_by_state.ts new file mode 100644 index 00000000000..a42dbd44c4c --- /dev/null +++ b/src/locales/en_CA/location/postcode_by_state.ts @@ -0,0 +1,21 @@ +// https://en.wikipedia.org/wiki/Postal_codes_in_Canada +// The basic format is A1A 1A1 +// First letter is province/territory-specific +// Other letters do not allow D, F, I, O, Q, U +const suffix = '[0-9][A-HJ-NPRSTVW-Z] [0-9][A-HJ-NPRSTVW-Z][0-9]'; + +export default { + AB: `{{helpers.fromRegExp(T${suffix})}}`, // Alberta + BC: `{{helpers.fromRegExp(V${suffix})}}`, // British Columbia + MB: `{{helpers.fromRegExp(R${suffix})}}`, // Manitoba + NB: `{{helpers.fromRegExp(E${suffix})}}`, // New Brunswick + NL: `{{helpers.fromRegExp(A${suffix})}}`, // Newfoundland and Labrador + NS: `{{helpers.fromRegExp(B${suffix})}}`, // Nova Scotia + NT: `{{helpers.fromRegExp(X${suffix})}}`, // Northwest Territories + NU: `{{helpers.fromRegExp(X${suffix})}}`, // Nunavut + ON: `{{helpers.fromRegExp([KLMNP]${suffix})}}`, // Ontario + PE: `{{helpers.fromRegExp(C${suffix})}}`, // Prince Edward Island + QC: `{{helpers.fromRegExp([HJG]${suffix})}}`, // Quebec + SK: `{{helpers.fromRegExp(S${suffix})}}`, // Saskatchewan + YT: `{{helpers.fromRegExp(Y${suffix})}}`, // Yukon +}; From f05653c8190eff8620a52eaee2e9c46bddc28fb7 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Sat, 17 Aug 2024 21:51:12 +0700 Subject: [PATCH 2/3] Update postcode_by_state.ts Co-authored-by: ST-DDT --- src/locales/en_CA/location/postcode_by_state.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/en_CA/location/postcode_by_state.ts b/src/locales/en_CA/location/postcode_by_state.ts index a42dbd44c4c..656a49a4020 100644 --- a/src/locales/en_CA/location/postcode_by_state.ts +++ b/src/locales/en_CA/location/postcode_by_state.ts @@ -2,7 +2,7 @@ // The basic format is A1A 1A1 // First letter is province/territory-specific // Other letters do not allow D, F, I, O, Q, U -const suffix = '[0-9][A-HJ-NPRSTVW-Z] [0-9][A-HJ-NPRSTVW-Z][0-9]'; +const suffix = '[0-9][ABCEGHJ-NPRSTVW-Z] [0-9][ABCEGHJ-NPRSTVW-Z][0-9]'; export default { AB: `{{helpers.fromRegExp(T${suffix})}}`, // Alberta From 3fc43cc39d5d7c35316bda404aa22c6170459f83 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Sun, 18 Aug 2024 10:25:25 +0700 Subject: [PATCH 3/3] Update postcode_by_state.ts Co-authored-by: ST-DDT --- src/locales/en_CA/location/postcode_by_state.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/en_CA/location/postcode_by_state.ts b/src/locales/en_CA/location/postcode_by_state.ts index 656a49a4020..1e7ad6380e2 100644 --- a/src/locales/en_CA/location/postcode_by_state.ts +++ b/src/locales/en_CA/location/postcode_by_state.ts @@ -15,7 +15,7 @@ export default { NU: `{{helpers.fromRegExp(X${suffix})}}`, // Nunavut ON: `{{helpers.fromRegExp([KLMNP]${suffix})}}`, // Ontario PE: `{{helpers.fromRegExp(C${suffix})}}`, // Prince Edward Island - QC: `{{helpers.fromRegExp([HJG]${suffix})}}`, // Quebec + QC: `{{helpers.fromRegExp([GHJ]${suffix})}}`, // Quebec SK: `{{helpers.fromRegExp(S${suffix})}}`, // Saskatchewan YT: `{{helpers.fromRegExp(Y${suffix})}}`, // Yukon };