-- Teemu Välimäki <[EMAIL PROTECTED]> wrote
(on Tuesday, 29 January 2008, 04:53 PM +0200):
> On Tuesday 29 January 2008 16:21:49 Matthew Weier O'Phinney wrote:
> > > 4. Zend_Form validation for some reason doesn't display "is an empty
> > > string" to all empty elements. Only first element in display group has
> > > this. Those in no display group or those without one do not have this.
> > > Only error message, that the the string is not long enough.
> >
> > Of course it doesn't. It uses the error messages from the validators you
> > attach. If an element is required, it runs each validator on the chain,
> > and returns error messages accordingly.
> >
> > If you want to display 'is an empty string', you should add a 'NotEmpty'
> > validator as the first validator in the chain; if you want that to be
> > the only message displayed if the item is empty, make sure you set its
> > breakChainOnFailure flag to true.
> 
> I tracked this behavior to Alnum validator. It gives '' is an empty string.
> 
> Interesting, that there is required option too, which actually seems exactly 
> the same as NotEmpty except, that it does not give any errors. Could required 
> be linked to NotEmpty validator?

Required is not the same as NotEmpty. When the Required flag is set, if
no value has been passed for that element, it passes the value null to
the element's validator chain. If an element is not Required, then if no
value is passed, it does not attempt to validate the element.

Somebody else raised an interesting point, however; if an *empty* value
is passed to a non-Required (i.e., optional) element, we should probably
not perform validations (or have a flag for not requiring it to run
validations, i.e., ALLOW_EMPTY), and I'll be working on that
functionality sometime this week.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to