Class: Respect::InValidator

Inherits:
Validator show all
Defined in:
lib/respect/in_validator.rb

Instance Method Summary (collapse)

Methods inherited from Validator

constraint_name, #to_h

Constructor Details

- (InValidator) initialize(set)

A new instance of InValidator



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

def initialize(set)
  @set = set
end

Instance Method Details

- (Object) validate(value)



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

def validate(value)
  unless @set.include?(value)
    raise ValidationError, "#{value.inspect} is not included in #@set"
  end
end