Hi Troy,

I am happy to hear that you are using Zend_Validate; your feedback is
much appreciated!

> My suggestion is to change how the validation receives it values. For
> instance, you have an array as follows:
> 
> $aData = ('username' => 'someone', 'password' => 'somepass');

These data appear to have come from an authentication attempt. At the
present time, I think it would make most sense to use Zend_Auth for
authentication purposes.

We do not yet have a component that provides full functionality for
working with forms; this is a large undertaking, and there are a couple
of proposals for such:

Zend_Form - Simon Mundy & Ralf Eggert
http://framework.zend.com/wiki/x/DA4

Zend_Form_Controller Proposal - Simon Mundy
http://framework.zend.com/wiki/x/mQE

> You could pass this array to Zend_Validata as follows:
> 
> $valid = new Zend_Validate($aData);
> 
> Now each validator could be changed to accept another parameter indicating
> which element of the array the validator would validate. For example:
> 
> $valid->addValidator(new Zend_Validate_StringLength(8, 20), true,
> 'username');
> 
> This would validate the 'username' array element.

I have seen suggestions similar to this before. How would this support
multidimensional arrays? For example, assume that you need to validate
an array where:

$aData['favorites']['colors'] = array('red', 'blue');

> I think this could reduce the amount of code need to validate a form
> considerably.

Yes, though I think there is some confusion over the Zend_Validate
component. It alone is not intended to solve the problem of form
validation. It is intended to solve the problem of validating a single
value against possibly multiple criteria. Zend_Validate would provide
the foundation, however, on which to build a component that eases the
pain of working with form data.

I plan to have committed documentation for Zend_Validate today, and
hopefully it will be helpful to understanding its purpose as a low-level
component for generalized validation purposes, rather than a high-level,
fully integrated form validation component.

Maybe you are interested in contributing to a form component? There are
certainly many aspects to consider, and the proposals by Simon and Ralf
might be a good place to start.

Best regards,
Darby

Reply via email to