-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
allow_blank for Time types #1380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,6 +488,11 @@ def app | |
get '/disallow_boolean_blank', val: false | ||
expect(last_response.status).to eq(200) | ||
end | ||
|
||
it 'accepts value when time allow_blank' do | ||
get '/disallow_datetime_blank', val: Time.now | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did this fail before, just for completeness? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here a start of the error stack: Failure/Error: return if value == false || value.present? NoMethodError: undefined method `to_datetime' for false:FalseClass # .../.rvm/gems/ruby-2.3.0/gems/activesupport-3.2.19/lib/active_support/core_ext/date_time/calculations.rb:141:in `<=>' # ./lib/grape/validations/validators/allow_blank.rb:24:in `==' # ./lib/grape/validations/validators/allow_blank.rb:24:in `validate_param!' Here 'active_support/core_ext/date_time/calculations.rb:141': # Layers additional behavior on DateTime#<=> so that Time and # ActiveSupport::TimeWithZone instances can be compared with a DateTime. def <=>(other) super other.to_datetime end I'm not sure why ActiveSupport is calling (if you have any idea, please share, I'll be very grateful). I think the problem is much deeper, but I'm to lazy to digging it up. So, maybe solution what offered is not a solution, it's looks like hook, but it works fine and looks pretty good =) return value.present? || false == value |
||
expect(last_response.status).to eq(200) | ||
end | ||
end | ||
|
||
context 'in an optional group' do | ||
|
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.
You're such a C programmer ;)