Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Content validation fails due to zf2.4 BC issue #42

Closed
YonmaNBehalf opened this issue Apr 12, 2015 · 1 comment
Closed

Content validation fails due to zf2.4 BC issue #42

YonmaNBehalf opened this issue Apr 12, 2015 · 1 comment

Comments

@YonmaNBehalf
Copy link

zendframework/zendframework#7440 Causes content validation to fail when using a Resource builtin inputFilter object to validate properties not passed as part of a POST payload.
Example:

PUT /my/[:id]
{"property": "value"}

Validator is defined for both property and id. Validation for id is done inside MyResource::update

$this->getInputFilter()->setData(array('id' => $id));

This is done, because my API's id has to pass through a few filters (to perform sanitation, filtering and in some cases manipulation of values).

filter configuration would something like this (in v2.3):

'MyResource\\Validator' => array(
            0 => array(
                'name' => 'id',
                'required' => false,
                'filters' => array(
                    0 => array(
                        'name' => 'Zend\\Filter\\StringTrim',
                        'options' => array(),
                    ),
                    1 => array(
                        'name' => 'MySpecialFilter',
                    ),
                ),
                'validators' => array(
                    1 => array(
                        'name' => 'Zend\\I18n\\Validator\\Alnum',
                        'options' => array(),
                    ),
                ),
                'description' => '',
                'allow_empty' => true,
                'continue_if_empty' => true,
            ),
            1 => array(
                'name' => 'property',
                'required' => false,
                'validators' => array(
                    0 => array(
                        'name' => 'Zend\\Validator\\StringLength',
                        'options' => array(
                            'max' => 255,
                        ),
                    ),
                ),
                'description' => '',
                'allow_empty' => false,
                'continue_if_empty' => false,
            ),
....

According to @bakura10's comment in the above zf2 issue, this issue may not be resolved in zf2 at all.

@weierophinney
Copy link
Member

Please see zendframework/zendframework#7474 for a grid detailing how the various combinations of required, allow_empty, and continue_if_empty are intended to work (and how they were fixed to work starting in 2.4.1). Updating to ZF 2.4.1 or later will ensure consistency of operations going forward.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants