Inconsistent boolean behaviour #33692
Unanswered
rihardsgrislis
asked this question in
General
Replies: 1 comment
-
Feel free to send a PR - this could be a breaking change as old valid values could potentially be considered invalid visa/versa - I would suggest sending it to the master branch. The behavior of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
Is there any specific reason why
boolean
validation rule doesn't accept"true"
,"on"
,"yes"
but boolean helper method does?Validation:
https://laravel.com/docs/7.x/validation#rule-boolean
Requests:
https://laravel.com/docs/7.x/requests#retrieving-input
Issue I ran into:
A POST request is made to my service using form-data payload and
true
/false
values are turned into"true"
/"false"
. Using the boolean helper I wouldn't care wheter the request payload was sent as form data or JSON. But I can't set the validation rule to "boolean" because it won't accept"true"
/"false"
.Wouldn't it be great if boolean validation rule accepted "true", "on", and "yes" like the helper does thus aligning the behaviour of both?
P.S. For the boolean helper method Laravel uses PHPs
filter_var
withFILTER_VALIDATE_BOOLEAN
.Beta Was this translation helpful? Give feedback.
All reactions