-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArrayInput
: Accept non-array input without throwing an exception
#105
Conversation
Signed-off-by: George Steel <[email protected]>
Alters the behaviour of `ArrayInput` so that non-array input is deemed a validation failure instead of an exceptional condition. Signed-off-by: George Steel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :+
@@ -4,60 +4,30 @@ | |||
|
|||
namespace Laminas\InputFilter; | |||
|
|||
use function gettype; | |||
use Laminas\Validator\IsArray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy new tech :P
Marked as bug + improvement on purpose, BTW: it changes dependencies, so it can't go to a patch version |
Thankyou @Ocramius 🙏 |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function resetValue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gsteel After removing this, default value is null now instead of empty array. It looks like a breaking change.
Description
Alters the behaviour of
ArrayInput
so that non-array input is deemed a validation failure instead of an exceptional condition.Fixes #104
This could be considered a BC break, but it would never have previously been possible for a non-array value to be validated/filtered here, so it's more likely that no-one ever used this input type without wrapping its execution in a try/catch block.
Assuming users are using this input type, and they are wrapping with try, then the introduction of the IsArray validator will still provide graceful validation failure.