Module: ParamsSanitizer::Sanitizers::ExistValue::SanitizerMethods

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

Instance Method Summary collapse

Instance Method Details

#exist_value(key, default_value, min = nil, max = nil) ⇒ Object

Define rule of exist_value

Examples:

exist_value(:keyword, '')

Parameters:

  • key (String)

    key of parameter.

  • default_value (Object)

    default values when input not exist value or nil.



25
26
27
28
29
# File 'lib/params_sanitizer/sanitizers/exist_value.rb', line 25

def exist_value(key, default_value, min = nil, max = nil)
  check_duplicated_definition!(key)
  definitions[:exist_value] ||= Hash.new
  definitions[:exist_value][key.to_s] = { default_value: default_value }
end