views:

170

answers:

2

Hi,

how to validate letters and whitespaces using Zend Framework ?

A: 

i think Zend_Validate_Regex is best for this situation

Irmantas
He'll want to pass in a '/[\w\s]+/i' as his regex in this case.
dcousineau
+2  A: 

The Zend Framework does have a Zend_Validate_Alpha (as well as an alphanumeric version).

Normally it doesn't allow white space, but if you pass a true into the constructor of the Zend_Validate_Alpha class it will allow whitespace. Same with Zend_Validate_Alnum.

For example:

$validator = new Zend_Validate_Alpha(true); //will allow whitespace and non number letters
dcousineau