Class: RegexPresenceValidator
- Inherits:
-
Object
- Object
- RegexPresenceValidator
- Includes:
- RegexSettingValidation
- Defined in:
- lib/validators/regex_presence_validator.rb
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ RegexPresenceValidator
constructor
A new instance of RegexPresenceValidator.
- #valid_value?(val) ⇒ Boolean
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_message ⇒ Object
15 16 17 |
# File 'lib/validators/regex_presence_validator.rb', line 15 def I18n.t(@regex_error) end |
#valid_value?(val) ⇒ Boolean
11 12 13 |
# File 'lib/validators/regex_presence_validator.rb', line 11 def valid_value?(val) val.present? && regex_match?(val) end |