-- benxmy <ben...@gmail.com> wrote (on Monday, 02 February 2009, 01:58 PM -0800): <snip> > That said, I'd prefer to use the ZF standard message > when possible. Even if it worked, I'd be outta luck with a (') passing > validation. Do you know if the following syntax is correct for the regex > validator: > > protected $_validators = array( > 'field1' => array('regex',true,array('/[^a-zA-Z\'\-\ ]/'),
You're creating the validators array incorrectly. I'm assuming from your example that you're creating an array of field => validators arrays that you use to create your elements. The problem with how you've done it is that setValidators(), which is called when you pass validators via the constructor, expects that each element in the array is either a string or an array representing a single validator. Additionally, you can sometimes run into issues with order of operators, so I typically recommend using key/value pairs in each array defining a validator. Try the following: protected $_validators = array( 'field1' => array( array( 'validator' => true, 'breakChainOnFailure' => true, 'options' => array('/[^a-z\' -]/i'), ), ), ); Second, you'll notice I modified the regex a bit. The 'i' switch tells it to be case insensitive, which is easier than 'a-zA-Z'. Additionally, if you want to include a hyphen in the character class, it's a good practice to put it as the last character -- that way it doesn't require escaping either. > ..... > ); > ? > I've been getting that 'Missing argument 1...' error. This is because of how you were passing the validators previously. -- Matthew Weier O'Phinney Software Architect | matt...@zend.com Zend Framework | http://framework.zend.com/