Hi Dmitry,

per default the fields are not required.

You will have to set the option

$options = array(Zend_Filter_Input::PRESENCE =>
Zend_Filter_Input::PRESENCE_REQUIRED);
$input->setOptions($options);

and your url field will show up as missing.

If you want to have the field validated, you have to pass it in the data
array:

$input->setData(array('url' => 'invalid url'));

Cheers,
Sascha

Dmitry Shirokov schrieb:
> Hey guys.
> 
> I tested followig code and little confusing:
> 
>         Zend_Loader::loadClass('Zend_Filter_Input');
>        
>         $filters = array(
>             '*'         => array('StringTrim', 'StripTags')
>         );
> 
>         $validators = array(
>             'url' => array(
>                 'Hostname',
>                 'NotEmpty',
>             ),
>         );
>        
>         $input = new Zend_Filter_Input($filters, $validators);
>         // we are setting empty data-array
>         $input->setData(array());
>        
>         if ($input->isValid()) {
>             echo 'Valid!';
>         } else {
>             echo 'errors';
>         } 
> 
> So... result always "Valid!" why? I've tried play with Zend_Filter_Input
> options but always got same result. It's correct? :)
> Im using 1.0.2 version.
> 
> -- 
> Thanks, Dmitry

Reply via email to