Closed svycka closed 9 years ago
What you have there is correct. When I ran the above, every one of those passed except the third data set, [[], true]
. This makes sense, because:
In this case, absence of the value is the same as having a null
value when you validate the set.
I understand that this is almost the same but for me it is BC because before this https://github.com/zendframework/zend-inputfilter/issues/4 it was possible to do this. And now I will have to move this check from input filter to maybe hydrator because:
// when ['foo' => null]
$filter->getData(); // returns ['foo' => null]
// when ['foo' => '']
$filter->getData(); // returns ['foo' => '']
// when []
$filter->getData(); // returns []
they all are considred empty and when I pass this data to hydrator null and '' are run by hydrator but last one is ignored. @weierophinney how could I solve this with inputfilter?
I need an optional input lets say I expect data like
{name: "some name", age: 18}
or{name: "some name"}
but don't want{name: "some name" age: null}
and this is impossible to do now or I can't find a way how to do it. As an example I wrote a test for this, of course this does not pass:Maybe I overthinking this?