Class: Veto::InclusionValidator
- Inherits:
-
AttributeValidator
- Object
- AbstractValidator
- AttributeValidator
- Veto::InclusionValidator
- Defined in:
- lib/veto/validators/inclusion_validator.rb
Instance Method Summary collapse
Methods inherited from AttributeValidator
Methods inherited from AbstractValidator
Constructor Details
This class inherits a constructor from Veto::AttributeValidator
Instance Method Details
#validate(entity, attribute, value, errors, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/veto/validators/inclusion_validator.rb', line 5 def validate entity, attribute, value, errors, ={} set = .fetch(:in) inclusion_method = set.respond_to?(:cover?) ? :cover? : :include? = .fetch(:message, :inclusion) on = .fetch(:on, attribute) unless set.send(inclusion_method, value) errors.add(on, , set) end end |