diff --git a/CHANGELOG.md b/CHANGELOG.md index caae074..622bef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Drop support for end-of-life Ruby (< 3.3) and Rails (< 8.0); test on Ruby 3.3, 3.4 and 4.0 with Rails 8.0, 8.1 and main - Replace the defunct Travis CI setup with GitHub Actions +- 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. Thanks to ~ @Adeniyikayodee - 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 dd60dfb..2519399 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 21b4133..846d9b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1065,11 +1065,15 @@ ] }, NG: { - valid: %w[ - 071134 - 025663 - 662612 - 071135 + valid: [ + '071134', + '025663', + '662612', + '071135', + 'EK-01-A03-FK-01', + 'EK 01 A03 FK 01', + 'EK01A03FK01', + 'ek01a03fk01' ], invalid: [ nil, @@ -1077,7 +1081,10 @@ 'invalid_zip', '12345', '123456-123456', - 'D0D0D0' + 'D0D0D0', + 'EK-00-A03-FK-01', + 'EK-01-A03-FK-00', + 'EK-01-A03-FK-011' ] }, OM: {