-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add tests for coercing bad values to a boolean #2045
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
Here's an example of a CHANGELOG.md entry: * [#2045](https://github.com/ruby-grape/grape/pull/2045): Add tests for coercing bad values to a boolean - [@DanielHeath](https://github.com/DanielHeath). Generated by 🚫 danger |
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.
It would be better to move tests to that place.
I would prefer to coerce an empty string to |
IMO an empty string is an invalid value to assign a boolean and should be treated the same as (eg) passing a string to a numeric value. |
I tend to agree I would expect |
I think I agree, I'd want this to be |
Dry-types treats an empty string as invalid for the boolean type 🤔
|
Interesting. I don't know ;) |
@DanielHeath thanks for the test, the request was implemented 😉 |
I was going to open an issue, but thought that including code would help illustrate, so it's a PR instead.
Currently, if you supply "" for a boolean parameter, it does not get coerced at all - instead, it gets passed through.
I think that's confusing and inconsistent; it would be better to return
Nil
. Is that a sensible change?