Class: Grape::Validators::Json

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



5
6
7
8
9
10
11
# File 'lib/introspective_grape/validators.rb', line 5

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