Class: Grape::Validators::JsonHash

Inherits:
Object
  • Object
show all
Defined in:
lib/introspective_grape/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_param!(field, params) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/introspective_grape/validators.rb', line 27

def validate_param!(field, params)
  begin
    raise unless JSON.parse( params[field] ).is_a? Hash
  rescue StandardError
    raise Grape::Exceptions::Validation.new params: [@scope.full_name(field)], message: 'must be a valid JSON hash!'
  end
end