Module: RequestParamsValidation::Handler

Defined in:
lib/request_params_validation/handler.rb

Class Method Summary collapse

Class Method Details

.handle_request_params(resource, action, params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/request_params_validation/handler.rb', line 7

def self.handle_request_params(resource, action, params)
  request_definition = Definitions.get_request(resource, action)

  unless request_definition
    case RequestParamsValidation.on_definition_not_found
    when :raise
      raise DefinitionNotFoundError.new(resource, action)
    else
      return
    end
  end

  RequestParamsValidation.remove_keys_from_params.each { |key| params.delete(key) }

  Params.validate!(request_definition.params, params)

  Params.filter!(request_definition.params, params) if RequestParamsValidation.filter_params
end