We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d14cd8 commit b721815Copy full SHA for b721815
lib/grape/validations/coerce.rb
@@ -26,13 +26,14 @@ def _valid_array_type?(type, values)
26
end
27
28
def _valid_single_type?(klass, val)
29
+ # allow nil, to ignore when a parameter is absent
30
+ return true if val.nil?
31
if klass == Virtus::Attribute::Boolean
32
val.is_a?(TrueClass) || val.is_a?(FalseClass)
33
elsif klass == Rack::Multipart::UploadedFile
34
val.is_a?(Hashie::Mash) && val.key?(:tempfile)
35
else
- # allow nil, to ignore when a parameter is absent
- val.nil? || val.is_a?(klass)
36
+ val.is_a?(klass)
37
38
39
0 commit comments