Class: Respect::MatchValidator
- Inherits:
-
Validator
- Object
- Validator
- Respect::MatchValidator
- Defined in:
- lib/respect/match_validator.rb
Instance Method Summary (collapse)
-
- (MatchValidator) initialize(pattern)
constructor
A new instance of MatchValidator.
- - (Object) validate(value)
Methods inherited from Validator
Constructor Details
- (MatchValidator) initialize(pattern)
A new instance of MatchValidator
3 4 5 |
# File 'lib/respect/match_validator.rb', line 3 def initialize(pattern) @pattern = pattern end |
Instance Method Details
- (Object) validate(value)
7 8 9 10 11 |
# File 'lib/respect/match_validator.rb', line 7 def validate(value) unless value =~ @pattern raise ValidationError, "#{value.inspect} does not match #{@pattern.inspect}" end end |