Description

UK postcodes tend to have the format:

AA1 1ZZ
A1 2ZZ
A11 2ZZ
AA11 2ZZ

When testing we have found that the latest 1.10-alpha version does not allow for this space in the formatting. Minor issue as developer can strip whitespace for validation and reformat for output, but it would be much better to have it accept the format that the public use.

Matthew Vivian has created a fix for this which we'll upload once we get relevant docs signed / etc.

Comments

Posted by Lloyd Watkin (lloydwatkin) on 2009-12-22T06:50:36.000+0000

Please contact us as we're not sure how to submit the fix (regex change required)

Posted by Thomas Weidner (thomas) on 2009-12-22T13:58:14.000+0000

Please note that it is not good behaviour to change code without asking the maintainer/developer (which is me in this case). ;-)

You should additionally note, when you've took a look at 1.10, that the regex is provided by CLDR, which is used within the I18n core and created by Unicode.

This means on the other hand that problems on the underlaying CLDR must be issues at Unicode (unicode.org/cldr) as ZF is not allowed to change CLDR and deliver such a version.

In such a case, that non-conform postcodes are wanted (even if they are common there must be a reason why the english maintainers at unicode dont match such a format), you should use a filter on the input before validation

I know I should probably post a separate bug report for this, but pretty much all of the default error messages in the validator use terrible English and could do with being updated. Error messages don't even include the invalid value, because the author forgot to add $this->_setValue($value) in the isValid method.

Debugging through the code, the format is returned as:
GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}