Fix Armenia postcode validation to accept 4-digit codes - #41131
Open
ssx wants to merge 1 commit into
Open
Conversation
|
Hi @ssx. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
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
force-pushed
the
feature/41130-armenia-postcode-4-digit
branch
from
August 19, 2026 08:13
074f8a8 to
a26aab8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (*)
Armenia replaced its 6-digit Soviet-era postal codes (
375NNN) with 4-digit codes (NNNN, range0001–4204) in 2006. TheAMentry inapp/code/Magento/Directory/etc/zip_codes.xmlstill 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
AMpattern_1regex with^[0-9]{4}$and updates the example to0010.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
AMare zero-padded 4-digit codes, e.g.000033for0033, entered to satisfy the broken validator).Both the PHP validators (
Magento\Directory\Model\Country\Postcode\Validator) and the frontend validators readMagento\Directory\Model\Country\Postcode\Config, so this single change covers server-side validation and the patterns injected intowindow.checkoutConfig.postCodes.Related Pull Requests
None.
Fixed Issues (if relevant)
Manual testing scenarios (*)
0010.375010(legacy 6-digit format) — validation correctly fails.Questions or comments
The integration test
Magento\Directory\Model\Country\Postcode\ValidatorTestis updated: theAMentry ingetPostcodesDataProvidernow uses0010, and dedicatedAMvalid/invalid data providers cover the range boundaries (0001,4204) and the rejected legacy format (375010).Contribution checklist (*)