Zend Framework

Postcode validator is too strict

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Trivial Trivial
  • Resolution: Won't Fix
  • Affects Version/s: 1.10.4
  • Fix Version/s: 1.10.7
  • Component/s: Zend_Validate
  • Labels:
    None

Description

Zend_Validate_PostCode

Example locale en_GB

ip14 4eg

This is a valid postcode and is accepted by all tested couriers in the UK and Royal mail .. it is rejected by Zend_Validate_PostCode.

The rejections are .. lower case alpha and the space.

Users virtually never correctly enter post codes perfectly so it seems over zealous to reject them for the reasons mentioned above.

strtoupper and trim spaces would have been a reasonable validation.

I realise that the script could do this but as an improvement to the validator I thought it worth mentioning.

A strict flag could be added to return to existing functionality.

Activity

Hide
Ryan Mauger added a comment -

The rejection for lowercase is not really an issue, the postcode specification uses uppercase letters, and you can simply apply the StringToUpper filter to the element which is to take the postcode.

The space however is a very good point, it actually features in the documentation of the specification for UK postcodes, (http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards/address/postcode.aspx). The space in a postcode does actually have purpose, as it divides two parts of the postcode which have separate meaning (see the link).

The specification also provides a regular expression which is the accepted standard in the UK for validating a postcode is of the correct format, and this regex includes the space character (see http://www.cabinetoffice.gov.uk/media/291370/bs7666-v2-0-xsd-PostCodeType.htm).

Show
Ryan Mauger added a comment - The rejection for lowercase is not really an issue, the postcode specification uses uppercase letters, and you can simply apply the StringToUpper filter to the element which is to take the postcode. The space however is a very good point, it actually features in the documentation of the specification for UK postcodes, (http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards/address/postcode.aspx). The space in a postcode does actually have purpose, as it divides two parts of the postcode which have separate meaning (see the link). The specification also provides a regular expression which is the accepted standard in the UK for validating a postcode is of the correct format, and this regex includes the space character (see http://www.cabinetoffice.gov.uk/media/291370/bs7666-v2-0-xsd-PostCodeType.htm).
Hide
David Stockton added a comment -

Please take a look at the patch attached.

I've updated the regex in the postalCodeData.xml file to include the space. I've also updated the PostCode validation tests since 3 or 4 of them were failing upon checkout.

I've also added a data driven test to PostCodeTest which includes the postal code mentioned in the defect report. The data includes the samples from the site indicated above as well as a few negative test cases based on characters that are not supposed to appear in certain positions. When the xml is updated, the tests all pass.

I did have to clear my cache initially to get this to work though as it appears the locale data is cached.

This is my first submission to the Zend Framework project. Please let me know if this is acceptable or if I need to do something else for it to be an acceptable patch submission.

Thanks,
David Stockton

Show
David Stockton added a comment - Please take a look at the patch attached. I've updated the regex in the postalCodeData.xml file to include the space. I've also updated the PostCode validation tests since 3 or 4 of them were failing upon checkout. I've also added a data driven test to PostCodeTest which includes the postal code mentioned in the defect report. The data includes the samples from the site indicated above as well as a few negative test cases based on characters that are not supposed to appear in certain positions. When the xml is updated, the tests all pass. I did have to clear my cache initially to get this to work though as it appears the locale data is cached. This is my first submission to the Zend Framework project. Please let me know if this is acceptable or if I need to do something else for it to be an acceptable patch submission. Thanks, David Stockton
Hide
Thomas Weidner added a comment -

Patch not accepted

Please note that ZF is not allowed and will not change the content of CLDR. When there is a problem with CLDR data please add a issue to http://unicode.org/CLDR which is the owner and maintainer of CLDR itself.

Show
Thomas Weidner added a comment - Patch not accepted Please note that ZF is not allowed and will not change the content of CLDR. When there is a problem with CLDR data please add a issue to http://unicode.org/CLDR which is the owner and maintainer of CLDR itself.
Hide
Thomas Weidner added a comment -

Closing as won't fix

Show
Thomas Weidner added a comment - Closing as won't fix
Hide
David Stockton added a comment -

Good to know. Thanks.

The link above is a 404 btw.

Show
David Stockton added a comment - Good to know. Thanks. The link above is a 404 btw.
Hide
David Stockton added a comment -

When is the CLDR updated in Zend Framework? I've entered a defect report for the CLDR (http://unicode.org/cldr/trac/ticket/2888).

Show
David Stockton added a comment - When is the CLDR updated in Zend Framework? I've entered a defect report for the CLDR (http://unicode.org/cldr/trac/ticket/2888).
Hide
Thomas Weidner added a comment -

Entering an issue into CLDR does not mean that Unicode gives out a new release of CLDR.

CLDR has a release-cycle of 6-8 months since more than 3 years.

Show
Thomas Weidner added a comment - Entering an issue into CLDR does not mean that Unicode gives out a new release of CLDR. CLDR has a release-cycle of 6-8 months since more than 3 years.
Hide
David Stockton added a comment -

I understand that entering an issue doesn't mean they will put out a new release. It doesn't even mean they will take my suggestion and update the regex for the GB post codes.

Thank you for your patience with me. I am new to contributing to ZF and simply trying to find places where I can contribute, but so far my efforts have been fruitless. It seems to be pretty difficult to determine bugs and issues that are entered that are actually ones that the team can fix or are willing to fix.

Show
David Stockton added a comment - I understand that entering an issue doesn't mean they will put out a new release. It doesn't even mean they will take my suggestion and update the regex for the GB post codes. Thank you for your patience with me. I am new to contributing to ZF and simply trying to find places where I can contribute, but so far my efforts have been fruitless. It seems to be pretty difficult to determine bugs and issues that are entered that are actually ones that the team can fix or are willing to fix.
Hide
Thomas Weidner added a comment -

@David:
Don't be frustrated. This is a learning process and every maintainer knows his components better than all others. You can't know the things I mentioned in the last 3 issues because you are new.

I would still ask you to keep trying fixing bugs. The longer you are doing this the better you will know the framework and the more issues will get fixed.

PS: I am normally responding within 2-3 days on my issues. So when you wait a week or so until I responded to an issue which is assigned to me you will not get frustrated

Keep on learning

Show
Thomas Weidner added a comment - @David: Don't be frustrated. This is a learning process and every maintainer knows his components better than all others. You can't know the things I mentioned in the last 3 issues because you are new. I would still ask you to keep trying fixing bugs. The longer you are doing this the better you will know the framework and the more issues will get fixed. PS: I am normally responding within 2-3 days on my issues. So when you wait a week or so until I responded to an issue which is assigned to me you will not get frustrated Keep on learning
Hide
David Stockton added a comment -

@Thomas: Thanks. When I got the "welcome" packet it mentioned that new issues are not assigned to people normally. It appears that almost all of them actually are since I saw < 20 issues that were truly unassigned. It's also a tough call since it looks like the average age of an issue is > 400 days right now according to the dashboard, so it's tough to tell if this is something that the maintainer either doesn't want to do, can't do, won't do, or just hasn't had time to look at. It would be to know if there is an intention of fixing or implementing a particular issue or if the maintainer would be open for help in determining the viability of a particular issue as well as the direction of the component - which ones are actually inline with the plans for the component.

Thanks,
David

Show
David Stockton added a comment - @Thomas: Thanks. When I got the "welcome" packet it mentioned that new issues are not assigned to people normally. It appears that almost all of them actually are since I saw < 20 issues that were truly unassigned. It's also a tough call since it looks like the average age of an issue is > 400 days right now according to the dashboard, so it's tough to tell if this is something that the maintainer either doesn't want to do, can't do, won't do, or just hasn't had time to look at. It would be to know if there is an intention of fixing or implementing a particular issue or if the maintainer would be open for help in determining the viability of a particular issue as well as the direction of the component - which ones are actually inline with the plans for the component. Thanks, David
Hide
Thomas Weidner added a comment -

There is a list of components and assigned maintainer/developer.
You just had the "problem" that you got on issues which are maintained by me... and I am one of those rare people who are very active

So to go on you could for example help Christian with Zend_Form issues... there are very much of them which should be solved. Or take a look at Zend_Dojo or Zend_View. I am sure that there are some "small" issues which need not much time to be solved.

Best would be to ask within IRC (#zftalk.dev) as such an discussion should not be hold within an issue.

Show
Thomas Weidner added a comment - There is a list of components and assigned maintainer/developer. You just had the "problem" that you got on issues which are maintained by me... and I am one of those rare people who are very active So to go on you could for example help Christian with Zend_Form issues... there are very much of them which should be solved. Or take a look at Zend_Dojo or Zend_View. I am sure that there are some "small" issues which need not much time to be solved. Best would be to ask within IRC (#zftalk.dev) as such an discussion should not be hold within an issue.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: