-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature(IE Postal): add postal code for Ireland #1083
feature(IE Postal): add postal code for Ireland #1083
Conversation
ezkemboi
commented
Aug 11, 2019
- Add postal code for Ireland as requested by @JoeEarly from issue Customise postcode validation #784
- Fixes request done on issue Customise postcode validation #784
src/lib/isPostalCode.js
Outdated
@@ -28,6 +28,7 @@ const patterns = { | |||
HR: /^([1-5]\d{4}$)/, | |||
HU: fourDigit, | |||
ID: fiveDigit, | |||
IE: /^[a-zA-Z0-9]{3}\b \b[a-zA-Z0-9]{4}$/i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified regex would be:
/^\w{3}\s\w{4}$/i
\w
will match any alphanumeric, see a good quick ref here.
However, it also looks to me like most of the areas, the routing key
is in the format of [alpha][digit][digit]
except for Dublin 6W
, so we could make it more specific?
/^[A-z]\d[\d|W]\s\w{4}$/i
nb: the i
can be left out too since the regex is wide enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking on this @profnandaa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, \s
will match tab and new line,
Should we allow for tabs and a new line for separation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, you we could just do an actual space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/^[A-z]\d[\d|w] \w{4}$/
- add postal code for ireland as requested by @JoeEarly from issue validatorjs#784 - fixes request done on issue validatorjs#784
b5515a6
to
0fe9155
Compare
@profnandaa updates made as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
And as always, thanks for the PR, Ez! 🎉 |