Module: ParamsSanitizer::Sanitizers::AcceptRegex::SanitizerMethods

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

Instance Method Summary collapse

Instance Method Details

#accept_regex(key, default_value, regex) ⇒ Object

Define rule of accept regex.

Examples:

accept_regex(:age, 0, /^\d+$/)


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

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