zendframework / zend-inputfilter

InputFilter component from Zend Framework
BSD 3-Clause "New" or "Revised" License
64 stars 50 forks source link

`getUnknown` in CollectionInputFilter #115

Closed michalbundyra closed 8 years ago

michalbundyra commented 8 years ago

Method getUnknown works wrong on CollectionInputFilter. It was returning all fields, not only unknown.

It should work similar to isValid method - so unknown fields should be checked for each dataset and result should be collection of unknown fields (to be more specific pairs field => value).

So for example: we have input filter with field "foo" (and we are using this input filter in our CollectionInputFilter). The input data are:

[
    ['foo' => 'bar'],
    ['baz' => 'bar'],
]

so the second dataset (index 1!) has unknown field baz.

The result of getUnknown method should be:

[
    1 => ['baz' => 'bar'],
]

but currently is exactly the same as the input data.

In this PR fixed behavior of this method in CollectionInputFilter + tests. Also updated method hasUnknown to reuse getUnknown results.

michalbundyra commented 8 years ago

Related to https://github.com/zfcampus/zf-content-validation/issues/82 - CollectionInputFilter::getUnknown returns always all fields.