diff --git a/lib/locales/en-GB.yml b/lib/locales/en-GB.yml index e3917d7baf..fe05c86272 100644 --- a/lib/locales/en-GB.yml +++ b/lib/locales/en-GB.yml @@ -1,7 +1,7 @@ en-GB: faker: address: - postcode: /[A-PR-UWYZ][A-HK-Y]?[0-9][ABEHMNPRVWXY0-9]? [0-9][ABD-HJLNP-UW-Z]{2}/ + postcode: /[A-PR-UWYZ]([A-HK-Y][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?) [0-9][ABD-HJLNP-UW-Z]{2}/ county: [Avon, Bedfordshire, Berkshire, Borders, Buckinghamshire, Cambridgeshire, Central, Cheshire, Cleveland, Clwyd, Cornwall, County Antrim, County Armagh, County Down, County Fermanagh, County Londonderry, County Tyrone, Cumbria, Derbyshire, Devon, Dorset, Dumfries and Galloway, Durham, Dyfed, East Sussex, Essex, Fife, Gloucestershire, Grampian, Greater Manchester, Gwent, Gwynedd County, Hampshire, Herefordshire, Hertfordshire, Highlands and Islands, Humberside, Isle of Wight, Kent, Lancashire, Leicestershire, Lincolnshire, Lothian, Merseyside, Mid Glamorgan, Norfolk, North Yorkshire, Northamptonshire, Northumberland, Nottinghamshire, Oxfordshire, Powys, Rutland, Shropshire, Somerset, South Glamorgan, South Yorkshire, Staffordshire, Strathclyde, Suffolk, Surrey, Tayside, Tyne and Wear, Warwickshire, West Glamorgan, West Midlands, West Sussex, West Yorkshire, Wiltshire, Worcestershire] uk_country: [England, Scotland, Wales, Northern Ireland] default_country: [England, Scotland, Wales, Northern Ireland] diff --git a/test/test_en_gb_locale.rb b/test/test_en_gb_locale.rb index 5739fb8e13..634a926c81 100644 --- a/test/test_en_gb_locale.rb +++ b/test/test_en_gb_locale.rb @@ -37,4 +37,12 @@ def test_gb_postcode_incode_is_valid incode = Faker::Address.postcode.split(' ')[1] assert_match(/\d[ABDEFGHJLNPQRSTUWXYZ]{2}/, incode) end + + def test_gb_postcode_outcode_is_valid + outcode = Faker::Address.postcode.split(' ')[0] + assert_includes(2..4, outcode.length) + assert_match(/\w{1,2}\d{1,2}\w?/,outcode) + assert_match(/^[A-PR-UWYZ][A-HK-Y0-9]/,outcode) + assert_match(/\w{1,2}\d{1,2}|\w\d[ABCDEFGHJKPSTUW]|\w\w\d[ABEHMNPRVWXY]/,outcode) + end end