Class: Committee::Middleware::Options::RequestValidation
- Defined in:
- lib/committee/middleware/options/request_validation.rb
Constant Summary collapse
- DEFAULTS =
Default values
{ strict: false, coerce_recursive: true, allow_get_body: false, check_content_type: true, check_header: true, optimistic_json: false, allow_form_params: true, allow_query_params: true, allow_non_get_query_params: false, allow_blank_structures: false, allow_empty_date_and_datetime: false, parameter_overwrite_by_rails_rule: true, request_body_hash_key: "committee.request_body_hash", query_hash_key: "committee.query_hash", path_hash_key: "committee.path_hash", headers_key: "committee.headers", params_key: "committee.params" }.freeze
Instance Attribute Summary collapse
-
#allow_blank_structures ⇒ Object
readonly
Returns the value of attribute allow_blank_structures.
-
#allow_empty_date_and_datetime ⇒ Object
readonly
Returns the value of attribute allow_empty_date_and_datetime.
-
#allow_form_params ⇒ Object
readonly
Returns the value of attribute allow_form_params.
-
#allow_get_body ⇒ Object
readonly
Returns the value of attribute allow_get_body.
-
#allow_non_get_query_params ⇒ Object
readonly
Returns the value of attribute allow_non_get_query_params.
-
#allow_query_params ⇒ Object
readonly
Returns the value of attribute allow_query_params.
-
#check_content_type ⇒ Object
readonly
Returns the value of attribute check_content_type.
-
#check_header ⇒ Object
readonly
Returns the value of attribute check_header.
-
#coerce_date_times ⇒ Object
readonly
Returns the value of attribute coerce_date_times.
-
#coerce_form_params ⇒ Object
readonly
Returns the value of attribute coerce_form_params.
-
#coerce_path_params ⇒ Object
readonly
Returns the value of attribute coerce_path_params.
-
#coerce_query_params ⇒ Object
readonly
Returns the value of attribute coerce_query_params.
-
#coerce_recursive ⇒ Object
readonly
Returns the value of attribute coerce_recursive.
-
#deserialize_parameters ⇒ Object
readonly
Returns the value of attribute deserialize_parameters.
-
#headers_key ⇒ Object
readonly
Returns the value of attribute headers_key.
-
#optimistic_json ⇒ Object
readonly
Returns the value of attribute optimistic_json.
-
#parameter_overwrite_by_rails_rule ⇒ Object
readonly
Returns the value of attribute parameter_overwrite_by_rails_rule.
-
#params_key ⇒ Object
readonly
Returns the value of attribute params_key.
-
#path_hash_key ⇒ Object
readonly
Returns the value of attribute path_hash_key.
-
#query_hash_key ⇒ Object
readonly
Returns the value of attribute query_hash_key.
-
#request_body_hash_key ⇒ Object
readonly
Returns the value of attribute request_body_hash_key.
-
#strict ⇒ Object
readonly
RequestValidation specific options.
Attributes inherited from Base
#accept_request_filter, #error_class, #error_handler, #ignore_error, #prefix, #raise_error, #schema, #schema_path, #strict_reference_validation
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RequestValidation
constructor
A new instance of RequestValidation.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ RequestValidation
Returns a new instance of RequestValidation.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/committee/middleware/options/request_validation.rb', line 34 def initialize( = {}) super() # Validation related @strict = .fetch(:strict, DEFAULTS[:strict]) @check_content_type = .fetch(:check_content_type, DEFAULTS[:check_content_type]) @check_header = .fetch(:check_header, DEFAULTS[:check_header]) @optimistic_json = .fetch(:optimistic_json, DEFAULTS[:optimistic_json]) # Type coercion related @coerce_date_times = [:coerce_date_times] @coerce_recursive = .fetch(:coerce_recursive, DEFAULTS[:coerce_recursive]) @coerce_form_params = [:coerce_form_params] @coerce_path_params = [:coerce_path_params] @coerce_query_params = [:coerce_query_params] # Parameter permission related @allow_form_params = .fetch(:allow_form_params, DEFAULTS[:allow_form_params]) @allow_query_params = .fetch(:allow_query_params, DEFAULTS[:allow_query_params]) @allow_get_body = .fetch(:allow_get_body, DEFAULTS[:allow_get_body]) @allow_non_get_query_params = .fetch(:allow_non_get_query_params, DEFAULTS[:allow_non_get_query_params]) @allow_blank_structures = .fetch(:allow_blank_structures, DEFAULTS[:allow_blank_structures]) @allow_empty_date_and_datetime = .fetch(:allow_empty_date_and_datetime, DEFAULTS[:allow_empty_date_and_datetime]) # Rails compatibility @parameter_overwrite_by_rails_rule = .fetch(:parameter_overwrite_by_rails_rule, DEFAULTS[:parameter_overwrite_by_rails_rule]) # Deserialization @deserialize_parameters = [:deserialize_parameters] # Hash keys @request_body_hash_key = .fetch(:request_body_hash_key, DEFAULTS[:request_body_hash_key]) @query_hash_key = .fetch(:query_hash_key, DEFAULTS[:query_hash_key]) @path_hash_key = .fetch(:path_hash_key, DEFAULTS[:path_hash_key]) @headers_key = .fetch(:headers_key, DEFAULTS[:headers_key]) @params_key = .fetch(:params_key, DEFAULTS[:params_key]) end |
Instance Attribute Details
#allow_blank_structures ⇒ Object (readonly)
Returns the value of attribute allow_blank_structures.
26 27 28 |
# File 'lib/committee/middleware/options/request_validation.rb', line 26 def allow_blank_structures @allow_blank_structures end |
#allow_empty_date_and_datetime ⇒ Object (readonly)
Returns the value of attribute allow_empty_date_and_datetime.
27 28 29 |
# File 'lib/committee/middleware/options/request_validation.rb', line 27 def allow_empty_date_and_datetime @allow_empty_date_and_datetime end |
#allow_form_params ⇒ Object (readonly)
Returns the value of attribute allow_form_params.
14 15 16 |
# File 'lib/committee/middleware/options/request_validation.rb', line 14 def allow_form_params @allow_form_params end |
#allow_get_body ⇒ Object (readonly)
Returns the value of attribute allow_get_body.
16 17 18 |
# File 'lib/committee/middleware/options/request_validation.rb', line 16 def allow_get_body @allow_get_body end |
#allow_non_get_query_params ⇒ Object (readonly)
Returns the value of attribute allow_non_get_query_params.
17 18 19 |
# File 'lib/committee/middleware/options/request_validation.rb', line 17 def allow_non_get_query_params @allow_non_get_query_params end |
#allow_query_params ⇒ Object (readonly)
Returns the value of attribute allow_query_params.
15 16 17 |
# File 'lib/committee/middleware/options/request_validation.rb', line 15 def allow_query_params @allow_query_params end |
#check_content_type ⇒ Object (readonly)
Returns the value of attribute check_content_type.
18 19 20 |
# File 'lib/committee/middleware/options/request_validation.rb', line 18 def check_content_type @check_content_type end |
#check_header ⇒ Object (readonly)
Returns the value of attribute check_header.
19 20 21 |
# File 'lib/committee/middleware/options/request_validation.rb', line 19 def check_header @check_header end |
#coerce_date_times ⇒ Object (readonly)
Returns the value of attribute coerce_date_times.
9 10 11 |
# File 'lib/committee/middleware/options/request_validation.rb', line 9 def coerce_date_times @coerce_date_times end |
#coerce_form_params ⇒ Object (readonly)
Returns the value of attribute coerce_form_params.
11 12 13 |
# File 'lib/committee/middleware/options/request_validation.rb', line 11 def coerce_form_params @coerce_form_params end |
#coerce_path_params ⇒ Object (readonly)
Returns the value of attribute coerce_path_params.
12 13 14 |
# File 'lib/committee/middleware/options/request_validation.rb', line 12 def coerce_path_params @coerce_path_params end |
#coerce_query_params ⇒ Object (readonly)
Returns the value of attribute coerce_query_params.
13 14 15 |
# File 'lib/committee/middleware/options/request_validation.rb', line 13 def coerce_query_params @coerce_query_params end |
#coerce_recursive ⇒ Object (readonly)
Returns the value of attribute coerce_recursive.
10 11 12 |
# File 'lib/committee/middleware/options/request_validation.rb', line 10 def coerce_recursive @coerce_recursive end |
#deserialize_parameters ⇒ Object (readonly)
Returns the value of attribute deserialize_parameters.
29 30 31 |
# File 'lib/committee/middleware/options/request_validation.rb', line 29 def deserialize_parameters @deserialize_parameters end |
#headers_key ⇒ Object (readonly)
Returns the value of attribute headers_key.
24 25 26 |
# File 'lib/committee/middleware/options/request_validation.rb', line 24 def headers_key @headers_key end |
#optimistic_json ⇒ Object (readonly)
Returns the value of attribute optimistic_json.
20 21 22 |
# File 'lib/committee/middleware/options/request_validation.rb', line 20 def optimistic_json @optimistic_json end |
#parameter_overwrite_by_rails_rule ⇒ Object (readonly)
Returns the value of attribute parameter_overwrite_by_rails_rule.
28 29 30 |
# File 'lib/committee/middleware/options/request_validation.rb', line 28 def parameter_overwrite_by_rails_rule @parameter_overwrite_by_rails_rule end |
#params_key ⇒ Object (readonly)
Returns the value of attribute params_key.
25 26 27 |
# File 'lib/committee/middleware/options/request_validation.rb', line 25 def params_key @params_key end |
#path_hash_key ⇒ Object (readonly)
Returns the value of attribute path_hash_key.
23 24 25 |
# File 'lib/committee/middleware/options/request_validation.rb', line 23 def path_hash_key @path_hash_key end |
#query_hash_key ⇒ Object (readonly)
Returns the value of attribute query_hash_key.
22 23 24 |
# File 'lib/committee/middleware/options/request_validation.rb', line 22 def query_hash_key @query_hash_key end |
#request_body_hash_key ⇒ Object (readonly)
Returns the value of attribute request_body_hash_key.
21 22 23 |
# File 'lib/committee/middleware/options/request_validation.rb', line 21 def request_body_hash_key @request_body_hash_key end |
#strict ⇒ Object (readonly)
RequestValidation specific options
8 9 10 |
# File 'lib/committee/middleware/options/request_validation.rb', line 8 def strict @strict end |