Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(location): en_CA postcodes by state #3057

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/locales/en_CA/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -14,6 +15,7 @@ const location: LocationDefinition = {
city_name,
city_pattern,
postcode,
postcode_by_state,
state,
state_abbr,
street_pattern,
Expand Down
21 changes: 21 additions & 0 deletions src/locales/en_CA/location/postcode_by_state.ts
Original file line number Diff line number Diff line change
@@ -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][ABCEGHJ-NPRSTVW-Z] [0-9][ABCEGHJ-NPRSTVW-Z][0-9]';

export default {
AB: `{{helpers.fromRegExp(T${suffix})}}`, // Alberta
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
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([GHJ]${suffix})}}`, // Quebec
SK: `{{helpers.fromRegExp(S${suffix})}}`, // Saskatchewan
YT: `{{helpers.fromRegExp(Y${suffix})}}`, // Yukon
};