Class: RegexPresenceValidator

Inherits:
Object
  • Object
show all
Includes:
RegexSettingValidation
Defined in:
lib/validators/regex_presence_validator.rb

Instance Method Summary collapse

Methods included from RegexSettingValidation

#initialize_regex_opts, #regex_match?

Constructor Details

#initialize(opts = {}) ⇒ RegexPresenceValidator

Returns a new instance of RegexPresenceValidator.



6
7
8
9
# File 'lib/validators/regex_presence_validator.rb', line 6

def initialize(opts = {})
  @opts = opts
  initialize_regex_opts(opts)
end

Instance Method Details

#error_messageObject



15
16
17
# File 'lib/validators/regex_presence_validator.rb', line 15

def error_message
  I18n.t(@regex_error)
end

#valid_value?(val) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/validators/regex_presence_validator.rb', line 11

def valid_value?(val)
  val.present? && regex_match?(val)
end