Class: Praxis::RequestStages::Validate

Inherits:
RequestStage show all
Defined in:
lib/praxis/request_stages/validate.rb

Instance Attribute Summary

Attributes inherited from Stage

#after_callbacks, #before_callbacks, #context, #name, #stages

Instance Method Summary collapse

Methods inherited from RequestStage

#execute_controller_callbacks, #execute_with_around, #path, #run

Methods inherited from Stage

#after, #application, #before, #callback_args, #execute_callbacks, #run, #setup!, #setup_deferred_callbacks!

Constructor Details

#initialize(name, context, **opts) ⇒ Validate

Returns a new instance of Validate.



6
7
8
9
10
11
12
13
# File 'lib/praxis/request_stages/validate.rb', line 6

def initialize(name, context,**opts)
  super
  # Add our sub-stages
  @stages = [
    RequestStages::ValidateParamsAndHeaders.new(:params_and_headers, context, parent: self),
    RequestStages::ValidatePayload.new(:payload, context, parent: self) 
  ]
end

Instance Method Details

#executeObject



15
16
17
18
19
# File 'lib/praxis/request_stages/validate.rb', line 15

def execute
  super
rescue Attributor::AttributorException => e
  return Responses::ValidationError.new(exception: e)
end