Hi Patrick,

you'll have to enable the "all fields are required" feature via the options first:

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

Cheers,
Sascha

pcalkins schrieb:
I posted this to core, but doesn't seem like many are subscribed to that - so
I am trying this list instead. Forgive me if its the wrong list :)

Code:

$input = array('customerId' => 3);

$filters = array(
        'customerId' => 'Digits',
        '*' => array(
                array('Alnum', true),
                'StringTrim'
        )
);
$validators = array(
        '*' => array(
                'allowEmpty' => true
        ),
        'customerId' => array(
                'presence' => 'required',
                array('GreaterThan', 0)
        ),
        'description' => array(
                'presence' => 'required'
        )
);

$filteredInput = new Zend_Filter_Input($filters, $validators, $input);

print_r($filteredInput->getErrors());
print_r($filteredInput->getMissing());

I would think that an error about the missing 'description' field would be
contained in the getErrors() method, but it is not. You have to use
getMissing() to find out, which contains a detailed message as opposed to
the shorter error messages available in getErrors(). Is this the correct
behavior??

Thanks-
Patrick Calkins

Reply via email to