0

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 article on ZF so I can pull this off (yet).

1 Answer 1

3

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)))
        );
Sign up to request clarification or add additional context in comments.

2 Comments

Spot on, Marcin! Thanks. I followed the addValidator('stringLength', false, array(1,100)) syntax.
For some reason I was using the very same syntax as nevvermind, which I copy pasted from somewhere. Thanks for the clarification :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.