diff options
| author | Matt Mayer <[email protected]> | 2024-08-20 03:14:56 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-19 20:14:56 +0000 |
| commit | b62c1b7a97fdb1ab5928d34b11bcad9e1158a60b (patch) | |
| tree | 12450c01a7e85454d8b649956ff3fbc64e58f3fa /src | |
| parent | cc7715bebded681655b95f5afc368cb250a2eadf (diff) | |
| download | faker-b62c1b7a97fdb1ab5928d34b11bcad9e1158a60b.tar.xz faker-b62c1b7a97fdb1ab5928d34b11bcad9e1158a60b.zip | |
feat(location): en_CA postcodes by state (#3057)
Diffstat (limited to 'src')
| -rw-r--r-- | src/locales/en_CA/location/index.ts | 2 | ||||
| -rw-r--r-- | src/locales/en_CA/location/postcode_by_state.ts | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/locales/en_CA/location/index.ts b/src/locales/en_CA/location/index.ts index 9f6d2f7d..8103ffb4 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 00000000..1e7ad638 --- /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][ABCEGHJ-NPRSTVW-Z] [0-9][ABCEGHJ-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([GHJ]${suffix})}}`, // Quebec + SK: `{{helpers.fromRegExp(S${suffix})}}`, // Saskatchewan + YT: `{{helpers.fromRegExp(Y${suffix})}}`, // Yukon +}; |
