ZF-4379: Fail to validate empty array
Description
It's possible to make an empty array pass as a valid Int or any other type of validation because the validation step is completly skip in Zend_Filter_Input.
<?php set_include_path('../library/ZendFramework/' . PATH_SEPARATOR . get_include_path());
require_once "Zend/Loader.php"; Zend_Loader::registerAutoload(); $validator = array( 'age' => array( 'presence' => 'required', 'Int' ) );
$data = array( 'age' => array() );
$input = new Zend_Filter_Input(null, $validator, $data, array(Zend_Filter_Input::ALLOW_EMPTY => false));
if ( $input->isValid() ) { echo 'Age '; var_dump($data['age']); echo ' is valid!'; } else { echo 'Age is not valid'; }
Comments
Posted by Felix De Vliegher (felixdv) on 2008-11-08T06:49:05.000+0000
Fixed in revision #12430. Fix empty array validation with Zend_Filter_Input.
Posted by Wil Sinclair (wil) on 2008-11-13T14:09:58.000+0000
Changing issues in preparation for the 1.7.0 release.