Skip to content

Commit e780354

Browse files
authored
Improved address generation for Republic of Ireland (#1714)
1 parent 192d08a commit e780354

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/main/resources/en-IE.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,53 @@ en-IE:
77
- "#{first_name} #{last_name} #{last_name}"
88
address:
99
county: [Galway, Leitrim, Mayo, Roscommon, Sligo, Donegal, Cavan, Monaghan, Clare, Cork, Kerry, Limerick, Tipperary, Waterford, Carlow, Dublin, Kildare, Kilkenny, Laois, Longford, Louth, Meath, Offaly, Westmeath, Wexford, Wicklow]
10+
city: [Dublin, Cork, Limerick, Galway, Waterford, Kilkenny, Sligo, Killarney, Athlone, Drogheda]
11+
town_by_county:
12+
Carlow: Tullow
13+
Cavan: Bailieborough
14+
Clare: Ennis
15+
Cork: Mallow
16+
Donegal: Letterkenny
17+
Dublin: Swords
18+
Galway: Tuam
19+
Kerry: Tralee
20+
Kildare: Naas
21+
Kilkenny: Thomastown
22+
Laois: Portlaoise
23+
Leitrim: Carrick-on-Shannon
24+
Limerick: Newcastle West
25+
Longford: Longford
26+
Louth: Dundalk
27+
Mayo: Castlebar
28+
Meath: Navan
29+
Monaghan: Monaghan
30+
Offaly: Tullamore
31+
Roscommon: Roscommon
32+
Sligo: Sligo
33+
Tipperary: Clonmel
34+
Waterford: Dungarvan
35+
Westmeath: Mullingar
36+
Wexford: Enniscorthy
37+
Wicklow: Bray
38+
# Dublin postal districts (non-Eircode)
1039
dublin-postcode: [D01, D02, D03, D04, DO5, D06, D07, D08, D09, D10, D11, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, D22, D23, D24, D6W]
40+
# House/building number patterns (used by Address.buildingNumber)
41+
building_number: ["#", "##", "###", "####"]
42+
# Secondary address lines common in IE
43+
secondary_address: ["Apt ##", "Flat #", "Unit #", "Floor #", "Suite ###"]
44+
# Common Irish street types
45+
street_suffix: [Street, Road, Avenue, Lane, Drive, Park, Terrace, Grove, Close, Quay, Place, Square, Crescent, Court, Hill, View, Way, Parade, Rise, Walk]
46+
# Street names assembled similarly to it.yml
47+
street_name:
48+
- "#{street_suffix} #{Name.first_name}"
49+
- "#{street_suffix} #{Name.last_name}"
50+
# Street address with and without secondary component
51+
street_address:
52+
- "#{street_name} #{building_number}"
53+
- "#{street_name} #{building_number}, #{secondary_address}"
54+
# Full address templates, inspired by it.yml and Irish formatting
55+
full_address:
56+
- "#{street_address}, #{city}, Co. #{county}"
57+
- "#{street_address}, Dublin #{dublin-postcode}"
58+
- "#{street_address}, #{city}, #{default_country}"
1159
default_country: [Ireland, Republic of Ireland]

src/test/java/net/datafaker/providers/base/AddressTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class AddressTest {
3131
private static final Faker BELGIAN_FAKER = new Faker(new Locale("nl", "BE"));
3232
private static final Faker RU_FAKER = new Faker(new Locale("ru", "RU"));
3333
private static final Faker AU_FAKER = new Faker(new Locale("en", "AU"));
34+
private static final Faker IE_FAKER = new Faker(new Locale("en", "IE"));
3435
private static final Pattern CYRILLIC_LETTERS = Pattern.compile(".*[а-яА-Я].*");
3536

3637
private static final Condition<String> IS_A_NUMBER = new Condition<>(s -> {
@@ -329,6 +330,15 @@ void belgianZipcode() {
329330
void australiaAddress() {
330331
assertThat(AU_FAKER.address().fullAddress()).matches("(Unit|[0-9]).+, [A-Z].+, [A-Z]{2,3} [0-9]{4}");
331332
}
333+
334+
@RepeatedTest(10)
335+
void irishAddress() {
336+
String regex = "(?:.+, [A-Z].+, Co\\. [A-Z].+)|" +
337+
"(?:.+, Dublin D[A-Z0-9]{2,3})|" +
338+
"(?:.+, [A-Z].+, (?:Ireland|Republic of Ireland))";
339+
assertThat(IE_FAKER.address().fullAddress()).matches(regex);
340+
}
341+
332342
@RepeatedTest(10)
333343
void testCityCnSuffix() {
334344
assertThat(new Faker(Locale.CHINA).address().citySuffix()).matches("[\\u4e00-\\u9fa5]{1,7}(?:省|自治区)");

0 commit comments

Comments
 (0)