Module: ParamsSanitizer::Sanitizers::RejectRange::SanitizerMethods

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

Instance Method Summary collapse

Instance Method Details

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

Define rule of reject range.

Examples:

reject_range(:age, 100, 100, nil)  # max 100.

Parameters:

  • key (String)

    key of parameter.

  • default_value (Object)

    default values when input not addmitted value.

  • min (Integer) (defaults to: nil)

    range of min.(when do not set a limit, nil)

  • max (Integer) (defaults to: nil)

    range of max.(when do not set a limit, nil)



49
50
51
52
53
# File 'lib/params_sanitizer/sanitizers/reject_range.rb', line 49

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