Class: Sinatra::ParamValidator::Validator::Form

Inherits:
Sinatra::ParamValidator::Validator show all
Defined in:
lib/sinatra/param_validator/validator/form.rb

Overview

A form validator

Defined Under Namespace

Modules: Helpers

Instance Attribute Summary

Attributes inherited from Sinatra::ParamValidator::Validator

#errors

Instance Method Summary collapse

Methods inherited from Sinatra::ParamValidator::Validator

inherited, #initialize, #success?

Constructor Details

This class inherits a constructor from Sinatra::ParamValidator::Validator

Instance Method Details

#handle_failure(context) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/sinatra/param_validator/validator/form.rb', line 35

def handle_failure(context)
  case context.request.preferred_type.to_s
  when 'application/json' then return json_failure(context)
  when 'text/html'
    return flash_failure(context) if defined? Sinatra::Flash
  end

  context.halt 400
end

#run(context) ⇒ Object



45
46
47
48
# File 'lib/sinatra/param_validator/validator/form.rb', line 45

def run(context)
  @original_params = context.params
  super(context)
end