Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[6.x] Add boolean($key) method to Request #31160
This PR introduces a new helper method to the
// Before $availableForHire = filter_var(Request::boolean('available_for_hire'), FILTER_VALIDATE_BOOLEAN); // After $availableForHire = Request::boolean('available_for_hire');
I set the default to be
Unsure how everyone feels about this and the naming of it though.
(edit: removed references to FILTER_NULL_ON_FAILURE as it was removed from the code)
Honestly I did not want to at first, but figured if the value is something entirely different than a Boolean (“hello world”) then it probably shouldn’t be one? But I don’t know.
Personally I never use it myself but thought I’d hear screams if not used, haha.
— edit —
So I am 100% up for removing that!
What is the point of this while we don't allow string values like "on"/"off" inside validation?
@LasseRafn How this simplifies the code while the validator doesn't accept "false", "true", "on", "off", string values? also, in PHP, values like, 0, 1, "0", "1", can be considered as booleans, which are already accepted by the validator.