Skip to content
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

Coerce an empty string to nil in case of the bool type #2049

Merged
merged 1 commit into from
May 3, 2020

Conversation

dnesteryuk
Copy link
Member

Satisfies a pending test in #2045

@dnesteryuk dnesteryuk force-pushed the empty_string_and_bool branch 2 times, most recently from 7d83410 to 7404f1e Compare May 3, 2020 13:31
@@ -46,7 +46,7 @@ def call(val)

attr_reader :type

# This method maintaine logic which was defined by Virtus. For example,
# This method maintain logic which was defined by Virtus. For example,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we fixing this, let's actually fix it with "This method maintains" :)

@@ -55,6 +55,12 @@ def reject?(val)
(val.is_a?(String) && type == Hash) ||
(val.is_a?(Hash) && type == String)
end

# Dry-Types treats an empty string as invalid. However, Grape community wants to have
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should explain why and link to the issue. How about: "However, Grape considers an empty string as absence of value and coerces it into nil."?

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge after cosmetic fixes in comments.

@dnesteryuk dnesteryuk force-pushed the empty_string_and_bool branch 3 times, most recently from 6cd7fce to 9f49439 Compare May 3, 2020 18:03
@dnesteryuk dnesteryuk merged commit 23374d6 into master May 3, 2020
@dnesteryuk dnesteryuk deleted the empty_string_and_bool branch May 3, 2020 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants