Closed codeaid closed 6 years ago
I know this is not a discussion board or Stack Overflow…
We have a forum for this: https://discourse.zendframework.com/ 😃
If we break down all your text to one word then we get optional. Now we look in the documentation and find: "Optional Input Filters". 😃
I know this is not a discussion board or Stack Overflow, however, having tried to find a solution to my problem (which I'm sure I'm not only one having) I wanted to raise a discussion about the following issue. There's a possibility that I've missed something along the way but I'll ask nonetheless.
Currently there doesn't seem to be a way to set input filter nested inside another input filter as required. Requirements seem to be based on the input (and not input filter) nearest to the root of the object.
To illustrate what I mean, assume the following API endpoint payload, which eventually gets converted to a PHP array:
If understand correctly then the only way to build validation for the specified structure is to have an input filter class for the whole object, which has an input filter attached for the
root
key, which in turn has an input filter class attached forbranch
. The latter one then has an input attached to it validating the value.In my use case, it is not required to specify
branch
when posting the payload, however, if it's present,leaf
has to be validated to make sure that the value is a boolean value.Currently the only way to avoid the
Value is required and can't be empty
on theleaf
property is to set is as not required, which obviously isn't how it should be.I've been looking through the source code and, correct me if I'm wrong, but it doesn't look like there's any functionality allowing to specify that a nested input filter is required or not. Is it a deliberate decision or something that's not been implemented or requested? Alternatively, maybe there's a different solution to achieve the same exact result I need?