Class: AttrValidator::Validators::RegexpValidator
- Inherits:
-
Object
- Object
- AttrValidator::Validators::RegexpValidator
- Defined in:
- lib/attr_validator/validators/regexp_validator.rb
Class Method Summary collapse
-
.validate(value, regexp) ⇒ Array
Validates that given value match regexp if regexp validation exists.
- .validate_options(regexp) ⇒ Object
Class Method Details
.validate(value, regexp) ⇒ Array
Validates that given value match regexp if regexp validation exists
7 8 9 10 11 12 13 14 15 |
# File 'lib/attr_validator/validators/regexp_validator.rb', line 7 def self.validate(value, regexp) return [] if value.nil? errors = [] unless !!regexp.match(value) errors << AttrValidator::I18n.t('errors.does_not_match') end errors end |
.validate_options(regexp) ⇒ Object
17 18 19 |
# File 'lib/attr_validator/validators/regexp_validator.rb', line 17 def self.(regexp) AttrValidator::ArgsValidator.is_string_or_regexp!(regexp, :validation_rule) end |