Class: ReeValidator::ValidateRegexp
- Inherits:
-
Object
- Object
- ReeValidator::ValidateRegexp
- Includes:
- Ree::FnDSL
- Defined in:
- lib/ree_lib/packages/ree_validator/package/ree_validator/functions/validate_regexp.rb
Constant Summary collapse
- RegexpErr =
Class.new(StandardError)
Instance Method Summary collapse
Instance Method Details
#call(value, regexp, error = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ree_lib/packages/ree_validator/package/ree_validator/functions/validate_regexp.rb', line 17 def call(value, regexp, error = nil) if !regexp.match(value) error ||= RegexpErr.new( t( 'validator.regexp.error', {regexp: regexp.inspect}, default_by_locale: :en ) ) raise error end true end |