Module: ParamsSanitizer::Sanitizers::RejectValue::SanitizerMethods

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

Instance Method Summary collapse

Instance Method Details

#reject_value(key, default_value, reject_values) ⇒ Object

Define rule of reject value.

Examples:

reject_value(:user_name, nil, ['admin','root'])

Parameters:

  • key (String)

    key of parameter.

  • default_value (Object)

    default values when input not addmitted value.

  • reject_values (Array<Object>)

    reject values.



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

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