Class: Respect::GreaterThanValidator

Inherits:
Validator
  • Object
show all
Defined in:
lib/respect/greater_than_validator.rb

Instance Method Summary (collapse)

Methods inherited from Validator

constraint_name, #to_h

Constructor Details

- (GreaterThanValidator) initialize(min)

A new instance of GreaterThanValidator



3
4
5
# File 'lib/respect/greater_than_validator.rb', line 3

def initialize(min)
  @min = min
end

Instance Method Details

- (Object) validate(value)



7
8
9
10
11
# File 'lib/respect/greater_than_validator.rb', line 7

def validate(value)
  unless value > @min
    raise ValidationError, "#{value} is not greater than #@min"
  end
end