Zip validation for Indian Pincodes is incorrect.

yasheshb - March 18, 2008 - 14:09
Project:CCK Address Extensions
Version:5.x-1.6
Component:India-Code
Category:bug report
Priority:normal
Assigned:yasheshb
Status:needs review
Description

The zipcode validation for indian pincodes has the following

//zip code is 6 digits with a possible space after third. first set is 1-9, second is 0-9

This is incorrect. 400056 is a valid pincode and it will fail the preg_match

preg_match("^[1-9]{3}\s{0,1}[0-9]{3}$", $item['zip'])

the correct validation should be
//zip code is 6 digits with a possible space after third. first digit is 1-9, next 2 digits are 0-9, followed by an optional space and 3 digits in the set [0-9]
and the preg_match would be

preg_match("/^[1-9]{1}[0-9]{2}\s{0,1}[0-9]{3}$/", $item['zip'])

AttachmentSize
cck_address_india.module.patch1.23 KB

#1

rconstantine - March 20, 2008 - 04:48

That's interesting. All of the regular expressions at (... oh, what is that site ... it's a huge regex library ... I can't seem to find it ...) agreed with the former definition. Could you point me to an online source with examples of ZIP codes like you describe? I just need a second confirmation.

However, as you'll see in other posts, I am currently unable to change the repository because it is screwed up. I may close this project and open a new one if it isn't fixed soon. So if I add your change, it will go in as soon as possible.

 
 

Drupal is a registered trademark of Dries Buytaert.