Zend_Filter_Input and validating plain HTML forms
ZF 1.11.2 here.
I have something like this in my controller:
$validators = array(
'username' => array('Alnum', array('stringLength', false, array('min' => 3, 'max' => 100))),
'password' => array('Alnum', array('stringLength', false, array('min' => 3, 'max' => 100)))
);
$input = new Zend_Filter_Input($filters, $validators, $_POST);
My problem is that, no matter how I submit the values, I always get: 'somevalue' is more than 1 characters long
. I couldn't find some art开发者_运维问答icle on ZF so I can pull this off (yet).
I think there shouldn't be false
parameter for stringLength. Your $validators
array should be as follows:
$validators = array(
'username' => array('Alnum', array('stringLength', array('min' => 3, 'max' => 100))),
'password' => array('Alnum', array('stringLength', array('min' => 3, 'max' => 100)))
);
精彩评论