Module: ParamsSanitizer::Sanitizers::RejectRegex::SanitizerMethods

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

Instance Method Summary collapse

Instance Method Details

#reject_regex(key, default_value, regex) ⇒ Object

Define rule of reject regex.

Examples:

reject_regex(:number, 0, /^\w$/)

Parameters:

  • key (String)

    key of parameter.

  • default_value (Object)

    default values when input not addmitted value.

  • regex (Regexp)

    reject when regex match.



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

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