I'm sorry, I should have included in my previous post that I tried that while
playing around with it, but if I take the "^" out of the expression it
returns 'true' as soon as it hits an applicable character that matches the
expression, so if I input a string such as "Gravit8" it will return true (G
being the first match), when I need it to return false (for the 8).



Matthew Weier O'Phinney-3 wrote:
> 
> -- benxmy <[email protected]> wrote
> (on Thursday, 05 February 2009, 12:20 PM -0800):
>> 
>> So I figured it out to an extent, but I think I'm still one step off and
>> I
>> haven't been able to track down the exact syntax for using regex in this
>> context.  I changed the $_validators array to:
>> 
>> ****
>>      protected $_validators = 
>>              'lname' => array(array('Regex','/[^a-z\'-]/i'))
>>      );
>> ****
>> And it kind of works, except to the opposite!  The regex validator will
>> return false if I have a clean string (because it doesn't actually match
>> anything) and true if I have a bad character in there (a 7, for example),
>> so
>> it validates the wrong way.  I assume there's a way to reverse that in
>> ZF,
>> but I haven't been able to find the correct syntax.  Is that possible? 
>> Or
>> do I need to alter the expression itself?
> 
> The expression is matching any value that is *not* alphabetic, a single
> quote, or a dash. Just omit the '^' in your character class (which is a
> negate operator), and you should be good.
> 
> 
>> Matthew Weier O'Phinney-3 wrote:
>> > 
>> > -- benxmy <[email protected]> wrote
>> > (on Tuesday, 03 February 2009, 11:27 AM -0800):
>> >> 
>> >> Still not quite there.  I believe I may be using Zend_Filter_Input
>> >> incorrectly.  I made the changes to my $_validators array as described
>> >> and
>> >> now it throws the following exception
>> >> 
>> >> Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception'
>> with
>> >> message 'Plugin by name 1 was not found in the registry.' 
>> >> ...
>> >> Zend_Loader_PluginLoader->load('1')
>> >> 
>> >> Just for reference, when I print out the $_validators array that's
>> passed
>> >> to
>> >> my validation function, this is the result:
>> >> 
>> >> Array ( [field1] => Array ( [0] => Array ( [validator] => 1
>> >> [breakChainOnFailure] => 1 [options] => Array ( [0] => /[^a-z'-]/i ) )
>> )
>> >> ) 
>> > 
>> > Okay, I'm sorry -- I misled you. I though you were using Zend_Form,
>> > which has a slightly different notation.
>> > 
>> > I'll review the thread later and see if I can diagnoes further.
>> > 
>> >> So it looks as if it's taking the 'true' in either the validator value
>> or
>> >> the breakchainonfailure value of the array and trying to load it. 
>> I've
>> >> tried to script it in a few different ways and triple-checked that I
>> have
>> >> the $_validators array set up correctly (testing with only the single
>> >> field)
>> >> and get the same exception.  
>> >> 
>> >> 
>> >> 
>> >> Matthew Weier O'Phinney-3 wrote:
>> >> > 
>> >> > -- benxmy <[email protected]> wrote
>> >> > (on Monday, 02 February 2009, 01:58 PM -0800):
>> >> > 
>> >> > 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'),
>> >> >             ),
>> >> >         ),
>> >> >     );
>> >> > 
>> >> > 
>> >> 
>> >> -- 
>> >> View this message in context:
>> >>
>> http://www.nabble.com/getMessages%28%29-crashes-with-quotes%21-tp21793751p21817057.html
>> >> Sent from the Zend Framework mailing list archive at Nabble.com.
>> >> 
>> > 
>> > -- 
>> > Matthew Weier O'Phinney
>> > Software Architect       | [email protected]
>> > Zend Framework           | http://framework.zend.com/
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/getMessages%28%29-crashes-with-quotes%21-tp21793751p21860299.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | [email protected]
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/getMessages%28%29-crashes-with-quotes%21-tp21793751p21861621.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to