Class: Grape::Validators::JsonHash

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

Instance Method Summary collapse

Instance Method Details

#validate_param!(field, params) ⇒ Object



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

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