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

values validator can no longer accept a range #881

Closed
smathieu opened this issue Jan 6, 2015 · 1 comment
Closed

values validator can no longer accept a range #881

smathieu opened this issue Jan 6, 2015 · 1 comment
Labels

Comments

@smathieu
Copy link

smathieu commented Jan 6, 2015

We're currently migration from grape 0.9.0 to 0.10.1. This validator that use to work now stopped working:

    params do
      requires :score, type: Integer, values: 0..10, desc: "..."
    end

relevant stacktrace:

     TypeError:
       no implicit conversion of Range into Array

     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/validators/values.rb:14:in `validate_param!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/validators/base.rb:17:in `block in validate!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/attributes_iterator.rb:15:in `block (2 levels) in each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/attributes_iterator.rb:14:in `each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/attributes_iterator.rb:14:in `block in each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/attributes_iterator.rb:13:in `each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/attributes_iterator.rb:13:in `each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/validations/validators/base.rb:15:in `validate!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/endpoint.rb:235:in `block in run'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/endpoint.rb:233:in `each'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/endpoint.rb:233:in `run'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/endpoint.rb:195:in `block in call!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/newrelic-grape-2.0.0/lib/newrelic-grape/instrument.rb:21:in `call'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/newrelic-grape-2.0.0/lib/newrelic-grape/instrument.rb:21:in `block in call!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/newrelic_rpm-3.9.9.275/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:366:in `perform_action_with_newrelic_trace'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/newrelic-grape-2.0.0/lib/newrelic-grape/instrument.rb:20:in `call!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/middleware/base.rb:18:in `call'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/middleware/base.rb:24:in `call!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/middleware/base.rb:18:in `call'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/middleware/base.rb:24:in `call!'
     # /Users/simon/.rvm/gems/ruby-2.2.0@rainforest/gems/grape-0.10.1/lib/grape/middleware/base.rb:18:in `call'

In this case, it's easy to convert the range to an array, but it might not be possible if you have a large range. It also feels like the range is more intention revealing than an array here.

@dblock
Copy link
Member

dblock commented Jan 8, 2015

This is likely a legit regression. Would appreciate a spec (and maybe a fix ;)).

@dblock dblock added the bug? label Jan 8, 2015
ajvondrak pushed a commit to ajvondrak/grape that referenced this issue Jan 16, 2015
ajvondrak pushed a commit to ajvondrak/grape that referenced this issue Jan 16, 2015
ajvondrak pushed a commit to ajvondrak/grape that referenced this issue Jan 17, 2015
@dblock dblock closed this as completed in 0b98900 Jan 17, 2015
dblock added a commit that referenced this issue Jan 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants