Skip to content

Commit

Permalink
Merge pull request #325 from Shopify/correct-zip-regex-patterns
Browse files Browse the repository at this point in the history
Correct zip regex patterns and make them Javascript-compatible
  • Loading branch information
rochlefebvre authored Dec 20, 2024
2 parents c7e5908 + 06196f0 commit dee2d88
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Set Malaysia and Singapore as tax_inclusive [#323](https://github.com/Shopify/worldwide/pull/323)
- Update or correct example zips [#324](https://github.com/Shopify/worldwide/pull/324)
- Correct zip regex patterns and make them Javascript-compatible [#325](https://github.com/Shopify/worldwide/pull/325)
---

## [1.15.0] - 2024-12-16
Expand Down
2 changes: 1 addition & 1 deletion data/regions/AC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ code: AC
unit_system: metric
currency: SHP
zip_example: ASCN 1ZZ
zip_regex: "\\A[Aa][Ss][Cc][Nn]\\s*1[Zz][Zz]\\z"
zip_regex: "^[Aa][Ss][Cc][Nn]\\s*1[Zz][Zz]$"
phone_number_prefix: 247
zip_autofill_enabled: true
format:
Expand Down
2 changes: 1 addition & 1 deletion data/regions/CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tax: 0.05
currency: CAD
unit_system: metric
tax_name: GST
zip_regex: "\\A[A-Za-z]\\d[A-Za-z]\\s*\\d[A-Za-z]\\d\\z"
zip_regex: "^[A-Za-z]\\d[A-Za-z]\\s*\\d[A-Za-z]\\d$"
partial_zip_regex: "^[A-Z][0-9][A-Z]$"
group: North American Countries
group_name: North America
Expand Down
2 changes: 1 addition & 1 deletion data/regions/GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ignore_zones: true
group: European Countries
group_name: Europe
zip_label: Postcode
zip_regex: '\A[A-Za-z]{1,2}[\d]{1,2}(?:[A-Za-z])?\s?[\d][A-Za-z]{2}\z'
zip_regex: "^[A-Za-z]{1,2}[\\d]{1,2}(?:[A-Za-z])?\\s?[\\d][A-Za-z]{2}$"
partial_zip_regex: "^[A-Z]{1,2}[0-9]{1,2}[A-Z]?$"
zip_example: SE22 8DL
phone_number_prefix: 44
Expand Down
2 changes: 1 addition & 1 deletion data/regions/IN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tax_name: CGST
tax_inclusive: true
group: Asian Countries
group_name: Asia
zip_regex: "\\A\\d{6}\\z"
zip_regex: "^\\d{6}$"
zip_example: '110034'
phone_number_prefix: 91
week_start_day: monday
Expand Down
4 changes: 2 additions & 2 deletions data/regions/JE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ tax_inclusive: true
group: European Countries
group_name: Europe
zip_example: JE1 1AA
zip_regex: "^JE[1-6] {0,2}\\d[A-Z]{2}$"
partial_zip_regex: "^JE[1-6]$"
zip_regex: "^JE\\d{1,2} {0,2}\\d[A-Z]{2}$"
partial_zip_regex: "^JE\\d{1,2}$"
phone_number_prefix: 44
format:
edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
Expand Down
4 changes: 2 additions & 2 deletions data/regions/JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ tax_inclusive: true
group: Asian Countries
group_name: Asia
zip_example: 154-0023
zip_regex: "\\A〒?(\\d{7}|[0-9|0-9]{3}(-|ー)[0-9|0-9]{4})\\z"
partial_zip_regex: "\\A〒?([0-9|0-9]{0,3})(-|ー?)([0-9|0-9]{0,4})\\z"
zip_regex: "^〒?(\\d{7}|[0-9|0-9]{3}(-|ー)[0-9|0-9]{4})$"
partial_zip_regex: "^〒?([0-9|0-9]{0,3})(-|ー?)([0-9|0-9]{0,4})$"
phone_number_prefix: 81
building_number_required: true
building_number_may_be_in_address2: true
Expand Down
2 changes: 1 addition & 1 deletion data/regions/KR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ unit_system: metric
tax_name: VAT
group: Asian Countries
group_name: Asia
zip_regex: "(\\A\\d{5}\\z|\\A\\d{3}-\\d{3}\\z)"
zip_regex: "^(\\d{5}|\\d{3}-\\d{3})$"
zip_example: '01600'
phone_number_prefix: 82
week_start_day: sunday
Expand Down
4 changes: 2 additions & 2 deletions data/regions/MQ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ group_name: Central America
tags:
- EU-OMR
zip_example: '97220'
zip_regex: "\\A(MQ-?)?((972)\\d{2,2})\\Z"
zip_regex: "^(MQ-?)?((972)\\d{2,2})$"
phone_number_prefix: 596
format:
edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{zip}{city}_{phone}"
show: "{firstName} {lastName}_{company}_{address1}_{address2}_{zip} {city}_{country}_{phone}"
# The only flag with official standing in Martinique is the French flag.
# The emoji flag sequence MQ renders as the "snake flag", which is resented by some as a symbol
# of the slave trade. A new local flag, the Iséité flag, was brought into use in 2019, but
# of the slave trade. A new local flag, the Iséité flag, was brought into use in 2019, but
# revoked in 2021. At this point, the safest course of action seems to be to use the French flag.
# Sources: https://en.wikipedia.org/wiki/Flag_of_Martinique
# https://www.rci.fm/martinique/infos/Justice/La-justice-annule-lutilisation-du-drapeau-et-de-lhymne-choisis-en-2019-par-la-CTM#
Expand Down
2 changes: 1 addition & 1 deletion data/regions/NL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group: European Countries
group_name: Europe
tags:
- EU-member
zip_regex: "(?-mix:\\A[1-9][0-9]{3} ?[A-Z]{2}\\z)"
zip_regex: "^[1-9][0-9]{3} ?[A-Z]{2}$"
partial_zip_regex: "^\\d{4}$"
zip_example: 1065 AM
phone_number_prefix: 31
Expand Down
2 changes: 1 addition & 1 deletion data/regions/NZ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tax_name: GST
tax_inclusive: true
group: Oceanian Countries
group_name: Oceania
zip_regex: "\\A\\d{4}\\z"
zip_regex: "^\\d{4}$"
zip_example: '6001'
phone_number_prefix: 64
building_number_required: true
Expand Down
2 changes: 1 addition & 1 deletion data/regions/PH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tax_name: VAT
zone_key: province
group: Asian Countries
group_name: Asia
zip_regex: "\\A\\d{4}\\z"
zip_regex: "^\\d{4}$"
zip_example: '1008'
phone_number_prefix: 63
week_start_day: sunday
Expand Down
2 changes: 1 addition & 1 deletion data/regions/PM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tags:
- EU-OCT
zip_example: '97500'
phone_number_prefix: 508
zip_regex: "\\A(PM-?)?((975)\\d{2,2})\\Z"
zip_regex: "^(PM-?)?((975)\\d{2,2})$"
format:
edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{zip}{city}_{phone}"
show: "{firstName} {lastName}_{company}_{address1}_{address2}_{zip} {city}_{country}_{phone}"
Expand Down
2 changes: 1 addition & 1 deletion data/regions/SA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tax: 0.15
currency: SAR
unit_system: metric
tax_name: VAT
zip_regex: "(?-mix:\\A\\d{5}(-\\d{4})?\\z)"
zip_regex: "^\\d{5}(-\\d{4})?$"
zip_requirement: optional
group: Asian Countries
group_name: Asia
Expand Down
2 changes: 1 addition & 1 deletion data/regions/TA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ unit_system: metric
# Source: https://en.wikipedia.org/wiki/Saint_Helena_pound
currency: GBP
zip_example: TDCU 1ZZ
zip_regex: "\\A[Tt][Dd][Cc][Uu]\\s*1[Zz][Zz]\\z"
zip_regex: "^[Tt][Dd][Cc][Uu]\\s*1[Zz][Zz]$"
phone_number_prefix: 2908
zip_autofill_enabled: true
autofill_city_enabled: true
Expand Down
2 changes: 1 addition & 1 deletion data/regions/UA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tax_inclusive: true
group: European Countries
group_name: Europe
zip_example: '15432'
zip_regex: "\\A\\d{5}\\z"
zip_regex: "^\\d{5}$"
phone_number_prefix: 380
week_start_day: monday
format:
Expand Down
2 changes: 1 addition & 1 deletion data/regions/US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group_name: North America
name_alternates:
- United States of America
zip_label: Zip code
zip_regex: "(?-mix:\\A\\d{5}(-\\d{4})?\\z)|(?i-mx:\\AFPO\\s*A[A-Z]\\s*\\d{5}-\\d{4}\\z)"
zip_regex: "^\\d{5}(-\\d{4})?$"
zip_example: '90210'
phone_number_prefix: 1
building_number_required: true
Expand Down

0 comments on commit dee2d88

Please sign in to comment.