Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DZone.com:
Zend_Validate for the win
Dec 03, 2010 @ 16:32:58

In this new post to DZone.com today Giorgio Sironi looks at what he considers one of the more valuable yet underestimated components of the Zend Framework - Zend_Validate.

Zend_Validate is a component of Zend Framework which provides validation classes which out-of-the-box enable you to check from string lengths to stranger properties like conformance to regular expressions or to a standard for barcodes. [...] Some parts of Zend_Validate are quite complex, and tie-in with the other components: there are file-related validations on size, hash and more to attach to your forms; in the domain-specific category instead, we can find validator for credit card numbers consistency, or barcodes; isbn codes; and more...

He includes a code sample to show of just some of the validators the component includes like: alpha-numeric, "between", valid email address, valid IP address, matches a regular expression and, a very handy feature of the component, setting up chains of validations.

tagged: zendvalidate example chain zendframework

Link:

Rob Allen's Blog:
Validating UK Postcodes
Nov 15, 2010 @ 18:29:35

Rob Allen has shared a bit of code he's put together to help with validating UK postal codes (since the functionality in Zend_Validate doesn't cooperate), so he extended the main Zend_Validate_PostCode with his own validator.

It's easy enough to add a filter to remove the space, but I'm a little worried that when (and if) it gets fixed, will the fixed version Zend_Validate_PostCode then fail to validate postcodes without the space? In theory it should as the space is part of the spec. I'd hate my code to unexpectedly break due to a valid bug fix. I can easy work around this worry though by simply creating my own extension of Zend_Validate_PostCode.

The thirty-five line code example allows you to correctly validate the postal code with a quick call to the "isValid" method. He also links to another method from Paul Court to handle things similarly.

tagged: postcode uk validation zendframework zendvalidate

Link:

Rob Allen's Blog:
Zend_Filter_Input / Zend_Validate Messages
Sep 17, 2007 @ 13:48:00

Rob Allen has been working with the Zend_Filter component of the Zend Framework and has discovered a few things:

The basic usage of Zend_Filter_Input is [a simple call to Zend_Filter_Input with the filter types and data to filter]. The problem is that the message you get out isn't always written as you would like. Consider the output if the body record is empty. The text isn't exactly what I would want to display to a user. To change it you pass in a messages parameter to the $validators array.

There's a long list of these "messages parameters" and Rob includes them in the post - things like NOT_ALNUM, CHECKSUM, QUOTED_STRING, INVALID_DASH and UNDECIPHERABLE_TLD (37 of them in all).

tagged: zendframework zendfilterinput zendvalidate messages list zendframework zendfilterinput zendvalidate messages list

Link:

Rob Allen's Blog:
Zend_Filter_Input / Zend_Validate Messages
Sep 17, 2007 @ 13:48:00

Rob Allen has been working with the Zend_Filter component of the Zend Framework and has discovered a few things:

The basic usage of Zend_Filter_Input is [a simple call to Zend_Filter_Input with the filter types and data to filter]. The problem is that the message you get out isn't always written as you would like. Consider the output if the body record is empty. The text isn't exactly what I would want to display to a user. To change it you pass in a messages parameter to the $validators array.

There's a long list of these "messages parameters" and Rob includes them in the post - things like NOT_ALNUM, CHECKSUM, QUOTED_STRING, INVALID_DASH and UNDECIPHERABLE_TLD (37 of them in all).

tagged: zendframework zendfilterinput zendvalidate messages list zendframework zendfilterinput zendvalidate messages list

Link:


Trending Topics: