Class: Rack::App::Middlewares::Params::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/app/middlewares/params/validator.rb

Constant Summary collapse

ValidateError =
Class.new(ArgumentError)

Instance Method Summary collapse

Constructor Details

#initialize(app, descriptor) ⇒ Validator

Returns a new instance of Validator.



4
5
6
7
# File 'lib/rack/app/middlewares/params/validator.rb', line 4

def initialize(app, descriptor)
  @descriptor = descriptor
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

> 422 required field missing | “422 Unprocessable Entity”



10
11
12
13
14
15
# File 'lib/rack/app/middlewares/params/validator.rb', line 10

def call(env)
  validate(env)
  @app.call(env)
rescue ValidateError => ex
  unprocessable_response(ex)
end