Created
October 30, 2012 20:49
-
-
Save alexshelkov/3982938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$factory = new \Zend\InputFilter\Factory(); | |
$i = $factory->createInputFilter(array( | |
'password' => array( | |
'name' => 'password', | |
'required' => true, | |
'validators' => array( | |
array( | |
'name' => 'not_empty', | |
), | |
array( | |
'name' => 'string_length', | |
'options' => array( | |
'min' => 8 | |
), | |
), | |
), | |
), | |
)); | |
$i->setData(array('password' => 'test')); | |
var_dump($i->isValid()); // false | |
// this is not required, but also may help, | |
// if you haven't got any "password" in your data it will be valid. But if it in data, it would not | |
$i->get('password')->setRequired(false); | |
// remove all validators | |
$i->get('password')->setValidatorChain(new \Zend\Validator\ValidatorChain()); | |
var_dump($i->isValid()); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment