Class: Respect::MinLengthValidator
- Inherits:
-
Validator
- Object
- Validator
- Respect::MinLengthValidator
- Defined in:
- lib/respect/min_length_validator.rb
Instance Method Summary (collapse)
-
- (MinLengthValidator) initialize(min_length)
constructor
A new instance of MinLengthValidator.
- - (Object) validate(value)
Methods inherited from Validator
Constructor Details
- (MinLengthValidator) initialize(min_length)
A new instance of MinLengthValidator
3 4 5 |
# File 'lib/respect/min_length_validator.rb', line 3 def initialize(min_length) @min_length = min_length end |
Instance Method Details
- (Object) validate(value)
7 8 9 10 11 12 |
# File 'lib/respect/min_length_validator.rb', line 7 def validate(value) unless value.length >= @min_length raise ValidationError, "#{value.inspect} must be at least #@min_length long but is #{value.length}" end end |