intridea/grape — pull request #516 by myitcv (2013-11-26 19:19:03+00:00)
Title: Validation and before block ordering

The test case as part of this PR highlights the problem in more detail, but the gist of it is:

```ruby
module CustomValidations
class Customvalidator < Grape::Validations::Validator
def validate_param!(attr_name, params)
unless params[attr_name] == 'im custom'
raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message: "is not custom!"
end
end
end
end

# elsewhere...

params do
requires :custom, customvalidator: true
end
resource ':custom' do
before do
val = params[:custom]
end
get do
'anything here'
end
end
```

The `before` block defined in the `namespace/resource` is evaluated before (no pun intended) the custom validator define on the params block of said namespace.

This doesn't seem to make much sense; I was expecting the validation to run before anything in the namespace (including the, now slightly confusingly called, `before` block)

Thoughts?