-
-
Notifications
You must be signed in to change notification settings - Fork 646
[2.5] Added the Valiator method isBoolean #197
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
Conversation
Thanks for the PR. Our variables are always strings though sent they? |
Yes all values are in the format of strings this method ensures they are in the format accepted as booleans - Yes, No, 1, 0, On and Off |
Has some weird indentation, but otherwise it looks sound. |
If FILTER_NULL_ON_FAILURE is set, FALSE is returned for "" from http://php.net/manual/en/filter.filters.validate.php
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.
I like it. It uses simple built-ins, but in my opinion there is one non-intuitive condition with filter_var
and FILTER_NULL_ON_FAILURE
which returns FALSE
on the empty string ""
which I don't think makes sense with dotenv (but maybe it does).
There needs to be some unit tests to accompany changes, and there's some minor whitespace consistency issues.
I submitted a pull request which should resolve all these issues.
Furthermore, while probably out of scope, it might be worth considering other edge cases such as (true)
like it's handled in the laravel framework.
add tests and fix empty string evaluated as false
whoops, looks like the tests are not compatible with ye olde php 5.3 fixed in https://github.com/sephedo/phpdotenv/pull/2 build: https://travis-ci.org/scratchers/phpdotenv/builds/198163739 |
fix backwards compat with php 5.3 array syntax
It's been a year. Any possibility of this getting merged? |
This looks pretty solid to me. Has tests and will not affect anyone if they are not using the boolean validator. |
No description provided.