-
-
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
Improvement in postcode validation #722
Comments
I'll look into it tomorrow. |
Thanks, You can additional missing post code from https://unipaygateway.info/countries https://en.wikipedia.org/wiki/List_of_postal_codes I am working on complete list for my own work, If i finish it then i will post it here , Thanks.
This all are renaming post codes regex,
|
dude this will take too much time specially because I can't just take the list above and use it since when I tried the GB regex from the links above the tests failed which means that I'll have to go over them one by one. |
I completed postcode validation for my work , May be i can pull and add related post code in list. I will check each regex and create test case (I have to do it anyways since i have to implement it). Then post a link for Testcase. |
@chikochavda that would be great, thank you in advance. |
Hello, You were right some of the test cases were failing in the list, This is working list for all pincodes regex with test cases, https://jsfiddle.net/ys7mtjsr/ I skipped few of the countries which belongs to your implementation (34 in total). I skipped few of those country which support only digits as pincodes as it not that complex (4 digit, 5 digits, 6 digits)(98 countries) Thanks |
@chikochavda man you don't use ^ and & which result in alot of false positives, you also don't surround your or statement in brackets which also results in false positives. That's what it found just by quickly running some tests, so I can't just use your list. since most of the list is just digits I'll take a look at them later and run over the non digits ones to make sure they are good. Thank you for the list, I just wanted to let you know about these issues incase you are using your list in something important. |
CLDR's postcode list is not maintained and was removed. I actually ditched validator's post code validation and implemented validation using data from Google's libaddressinput. Which provided me with validation for zip/postal/eircode/pin codes from countless countries. |
Hello Right now we have only 34 country for postcode validation, Can we add more country support for post code validation,
I found link which has postcode validation with different country
Original SO question
https://stackoverflow.com/questions/578406/what-is-the-ultimate-postal-code-and-zip-regex
Link for postcode regex source
http://unicode.org/cldr/trac/browser/tags/release-26-0-1/common/supplemental/postalCodeData.xml?rev=11071
I have tried few of them and it works as expected.
Thanks.
Possible json for regex postcode
{
"JE":"JEd[dA-Z]?[ ]?d[ABD-HJLN-UW-Z]{2}",
"GG":"GYd[dA-Z]?[ ]?d[ABD-HJLN-UW-Z]{2}",
"IM":"IMd[dA-Z]?[ ]?d[ABD-HJLN-UW-Z]{2}",
"BR":"d{5}[-]?d{3}",
"AX":"22d{3}",
"KR":"d{3}[-]d{3}",
"CN":"d{6}",
"SG":"d{6}",
"AD":"ADd{3}",
"AR":"([A-HJ-NP-Z])?d{4}([A-Z]{3})?",
"AM":"(37)?d{4}",
"AZ":"d{4}",
"BH":"((1[0-2]|[2-9])d{2})?",
"BD":"d{4}",
"BB":"(BBd{5})?",
"BY":"d{6}",
"BM":"[A-Z]{2}[ ]?[A-Z0-9]{2}",
"BA":"d{5}",
"IO":"BBND 1ZZ", //not sure
"BN":"[A-Z]{2}[ ]?d{4}",
"BG":"d{4}",
"KH":"d{5}",
"CV":"d{4}",
"CL":"d{7}",
"CR":"d{4:5}|d{3}-d{4}",
"HR":"d{5}",
"CY":"d{4}",
"DO":"d{5}",
"EC":"([A-Z]d{4}[A-Z]|(?:[A-Z]{2})?d{6})?",
"EG":"d{5}",
"EE":"d{5}",
"FO":"d{3}",
"GE":"d{4}",
"GL":"39d{2}",
"GT":"d{5}",
"HT":"d{4}",
"HN":"(?:d{5})?",
"HU":"d{4}",
"ID":"d{5}",
"JO":"d{5}",
"KZ":"d{6}",
"KW":"d{5}",
"LA":"d{5}",
"LV":"d{4}",
"LB":"(d{4}([ ]?d{4})?)?",
"LT":"d{5}",
"LU":"d{4}",
"MK":"d{4}",
"MY":"d{5}",
"MV":"d{5}",
"MT":"[A-Z]{3}[ ]?d{2:4}",
"MU":"(d{3}[A-Z]{2}d{3})?",
"MD":"d{4}",
"MC":"980d{2}",
"MA":"d{5}",
"NP":"d{5}",
"NZ":"d{4}",
"NI":"((d{4}-)?d{3}-d{3}(-d{1})?)?",
"NG":"(d{6})?",
"OM":"(PC )?d{3}",
"PK":"d{5}",
"PY":"d{4}",
"PH":"d{4}",
"PR":"00[679]d{2}([ -]d{4})?",
"SM":"4789d",//not sure
"SN":"d{5}",
"SK":"d{3}[ ]?d{2}",
"SI":"d{4}",
"LK":"d{5}",
"TJ":"d{6}",
"TH":"d{5}",
"TN":"d{4}",
"TR":"d{5}",
"TM":"d{6}",
"UA":"d{5}",
"UY":"d{5}",
"UZ":"d{6}",
"VA":"00120",//not sure
"VE":"d{4}",
"AS":"96799",//not sure
"CC":"6799",//not sure
"CK":"d{4}",
"RS":"d{6}",
"ME":"8d{4}",
"CS":"d{5}",
"YU":"d{5}",
"CX":"6798",//not sure
"ET":"d{4}",
"FK":"FIQQ 1ZZ",//not sure
"NF":"2899",//not sure
"FM":"(9694[1-4])([ -]d{4})?",
"GF":"9[78]3d{2}",
"GN":"d{3}",
"GP":"9[78][01]d{2}",
"GS":"SIQQ 1ZZ",//not sure
"GU":"969[123]d([ -]d{4})?",
"GW":"d{4}",
"HM":"d{4}",
"IQ":"d{5}",
"KG":"d{6}",
"LR":"d{4}",
"LS":"d{3}",
"MG":"d{3}",
"MH":"969[67]d([ -]d{4})?",
"MN":"d{6}",
"MP":"9695[012]([ -]d{4})?",
"MQ":"9[78]2d{2}",
"NC":"988d{2}",
"NE":"d{4}",
"VI":"008(([0-4]d)|(5[01]))([ -]d{4})?",
"PF":"987d{2}",
"PG":"d{3}",
"PM":"9[78]5d{2}",
"PN":"PCRN 1ZZ",
"PW":"96940",
"RE":"9[78]4d{2}",
"SH":"(ASCN|STHL) 1ZZ",
"SJ":"d{4}",
"SO":"d{5}",
"SZ":"[HLMS]d{3}",
"TC":"TKCA 1ZZ",
"WF":"986d{2}",
"XK":"d{5}",
"YT":"976d{2}"
}
The text was updated successfully, but these errors were encountered: