Skip to content

Commit c673d80

Browse files
authored
Merge pull request #354 from Shopify/update-regex-and-require-postcodes-in-MT
Require postcodes and update regex in MT
2 parents b37afe8 + 42666f1 commit c673d80

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2626
- Security in case of vulnerabilities.
2727

2828
## [Unreleased]
29+
- Require postcodes and update regex in MT [#354](https://github.com/Shopify/worldwide/pull/354)
2930

3031
---
3132

data/regions/MT.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ tax_inclusive: true
99
group: European Countries
1010
group_name: Europe
1111
phone_number_prefix: 356
12-
zip_regex: "^(MT?-?)?[ABĊCDEFĠGHĦIJKLMNOPQRSTUVWXYŻZ]{2,3}( ?\\d{2,4})?$"
13-
zip_requirement: recommended
12+
zip_regex: "^(MT-?)?([Tt][Pp]|[A-Za-z]{3}) ?[0-9]{4}$"
1413
tags:
1514
- EU-member
16-
zip_example: NXR 01
15+
zip_example: VLT 1933
1716
format:
1817
edit: "{country}_{firstName}{lastName}_{company}_{address1}_{address2}_{city}{zip}_{phone}"
1918
show: "{firstName} {lastName}_{company}_{address1}_{address2}_{city} {zip}_{country}_{phone}"

test/worldwide/regions/mt_test.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
module Worldwide
6+
class MtTest < ActiveSupport::TestCase
7+
setup do
8+
@region = Worldwide.region(code: "MT")
9+
end
10+
11+
test "zip codes with country prefix are valid" do
12+
assert @region.valid_zip?("MT-VLT 1933")
13+
assert @region.valid_zip?("MT-VLT1933")
14+
end
15+
16+
test "zip codes without country prefix are valid" do
17+
assert @region.valid_zip?("VLT 1933")
18+
assert @region.valid_zip?("VLT1933")
19+
end
20+
21+
test "two-letter zip codes from Tigné Point are valid" do
22+
assert @region.valid_zip?("TP 1933")
23+
assert @region.valid_zip?("TP1933")
24+
end
25+
26+
test "other two-letter zip codes are invalid" do
27+
assert_not @region.valid_zip?("AA 1933")
28+
end
29+
30+
test "pre-2007 formatted zip codes are invalid" do
31+
assert_not @region.valid_zip?("VLT 05")
32+
end
33+
34+
test "malformed zip codes are invalid" do
35+
assert_not @region.valid_zip?("VLT 193")
36+
assert_not @region.valid_zip?("VLT 19333")
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)