Module: ParamsSanitizer::Sanitizers::AcceptValue::SanitizerMethods

Defined in:
lib/params_sanitizer/sanitizers/accept_value.rb

Instance Method Summary collapse

Instance Method Details

#accept_value(key, default_value, accept_values) ⇒ Object

Define rule of accept value.

Examples:

accept_value(:order, 0, ['0','1'])

Parameters:

  • key (String)

    key of parameter.

  • default_value (Object)

    default values when input not addmitted value.

  • accept_values (Array<Object>)

    accept values.



45
46
47
48
49
# File 'lib/params_sanitizer/sanitizers/accept_value.rb', line 45

def accept_value(key, default_value, accept_values)
  check_duplicated_definition!(key)
  definitions[:accept_value] ||= Hash.new
  definitions[:accept_value][key.to_s] = { default_value: default_value, accept_values: accept_values }
end