Skip to content

Fix Armenia postcode validation to accept 4-digit codes - #41131

Open
ssx wants to merge 1 commit into
magento:2.4-developfrom
ssx:feature/41130-armenia-postcode-4-digit
Open

Fix Armenia postcode validation to accept 4-digit codes#41131
ssx wants to merge 1 commit into
magento:2.4-developfrom
ssx:feature/41130-armenia-postcode-4-digit

Conversation

@ssx

@ssx ssx commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description (*)

Armenia replaced its 6-digit Soviet-era postal codes (375NNN) with 4-digit codes (NNNN, range 00014204) in 2006. The AM entry in app/code/Magento/Directory/etc/zip_codes.xml still only matches six digits, so every valid Armenian postcode is rejected — on the customer address form, in the admin, and at checkout.

This replaces the AM pattern_1 regex with ^[0-9]{4}$ and updates the example to 0010.

No 6-digit pattern is kept alongside it. The old format has not been valid since 2006, so retaining it would only let invalid codes through and would not help existing data (6-digit values stored for AM are zero-padded 4-digit codes, e.g. 000033 for 0033, entered to satisfy the broken validator).

Both the PHP validators (Magento\Directory\Model\Country\Postcode\Validator) and the frontend validators read Magento\Directory\Model\Country\Postcode\Config, so this single change covers server-side validation and the patterns injected into window.checkoutConfig.postCodes.

Related Pull Requests

None.

Fixed Issues (if relevant)

  1. Fixes Armenia Postcode Validation is Incorrect #41130: Armenia Postcode Validation is Incorrect

Manual testing scenarios (*)

  1. Set the store's allowed countries to include Armenia.
  2. On the storefront, add a product to the cart and go to checkout.
  3. Enter an Armenian shipping address with postcode 0010.
  4. Before: validation fails, stating the postcode should be 6 characters. After: the postcode is accepted.
  5. Enter 375010 (legacy 6-digit format) — validation correctly fails.
  6. Repeat via Customer > Addresses in the admin and the customer account address form for the same results.

Questions or comments

The integration test Magento\Directory\Model\Country\Postcode\ValidatorTest is updated: the AM entry in getPostcodesDataProvider now uses 0010, and dedicated AM valid/invalid data providers cover the range boundaries (0001, 4204) and the rejected legacy format (375010).

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant

m2-assistant Bot commented Aug 19, 2026

Copy link
Copy Markdown

Hi @ssx. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

Armenia replaced its 6-digit Soviet-era postal codes (375NNN) with 4-digit
codes (NNNN, range 0001-4204) in 2006, but the AM pattern in
Magento/Directory/etc/zip_codes.xml still only matches six digits. Every valid
Armenian postcode is therefore rejected on the customer address form and at
checkout.

Replace the AM pattern_1 regex with `^[0-9]{4}$` and update its example to
`0010`. No 6-digit pattern is retained: the old format has not been in use
since 2006, so keeping it would only let invalid codes through.

Both the PHP validators and the frontend validators read
Magento\Directory\Model\Country\Postcode\Config, so this single change covers
server-side validation and the patterns injected into
window.checkoutConfig.postCodes.

Fixes magento#41130
@ssx
ssx force-pushed the feature/41130-armenia-postcode-4-digit branch from 074f8a8 to a26aab8 Compare August 19, 2026 08:13
@ct-prd-projects-boards-automation ct-prd-projects-boards-automation Bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Aug 19, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Armenia Postcode Validation is Incorrect

1 participant