From 7379c9fcc08c4a00dc8761ef677abf7a5fa38e01 Mon Sep 17 00:00:00 2001 From: mkbadeniyi Date: Thu, 8 Oct 2026 09:54:04 +0100 Subject: [PATCH 1/2] Accept Nigeria (NG) 11-character postcodes --- CHANGELOG.md | 1 + lib/validates_zipcode/cldr_regex_collection.rb | 2 +- spec/spec_helper.rb | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f526e7..3b2769a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## Unreleased +- Accept Nigeria's (NG) 11-character digital postcode, such as `EK-01-A03-FK-01`, alongside the six-digit code. NIPOST launched it in October 2026. - Fix the Moldova (MD) postcode pattern: accept the canonical `MD-####` form and bare 4-digit codes, and reject non-`MD` letter prefixes. The previous pattern required any two letters and rejected the hyphenated form — fixes #73 ## 0.6.0 diff --git a/lib/validates_zipcode/cldr_regex_collection.rb b/lib/validates_zipcode/cldr_regex_collection.rb index 9e9ba5f..b2addde 100644 --- a/lib/validates_zipcode/cldr_regex_collection.rb +++ b/lib/validates_zipcode/cldr_regex_collection.rb @@ -77,7 +77,7 @@ module CldrRegexpCollection MA: /\A\d{5}\z/, NZ: /\A\d{4}\z/, NI: /\A\d{5}\z/, - NG: /\A\d{6}\z/, + NG: /\A(\d{6}|[A-Z]{2}[- ]?(0[1-9]|[1-9]\d)[- ]?[A-Z0-9]{3}[- ]?[A-Z]{2}[- ]?(0[1-9]|[1-9]\d))\z/i, OM: /\A(PC )?\d{3}\z/i, PK: /\A\d{5}\z/, PY: /\A(\d{4}|\d{6})\z/, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 50c4d4f..329711a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1070,6 +1070,9 @@ 025663 662612 071135 + EK-01-A03-FK-01 + EK01A03FK01 + ek01a03fk01 ], invalid: [ nil, @@ -1077,7 +1080,10 @@ 'invalid_zip', '12345', '123456-123456', - 'D0D0D0' + 'D0D0D0', + 'EK-00-A03-FK-01', + 'EK-01-A03-FK-00', + 'EK-01-A03-FK-011' ] }, OM: { From 272ee6cdf8376fcb59a9c4a748623f41e90eb95c Mon Sep 17 00:00:00 2001 From: David Gil Date: Thu, 8 Oct 2026 15:56:56 +0200 Subject: [PATCH 2/2] Cover the spaced NG postcode form (EK 01 A03 FK 01) --- spec/spec_helper.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b55c29b..846d9b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1065,14 +1065,15 @@ ] }, NG: { - valid: %w[ - 071134 - 025663 - 662612 - 071135 - EK-01-A03-FK-01 - EK01A03FK01 - ek01a03fk01 + valid: [ + '071134', + '025663', + '662612', + '071135', + 'EK-01-A03-FK-01', + 'EK 01 A03 FK 01', + 'EK01A03FK01', + 'ek01a03fk01' ], invalid: [ nil,