Class: Toolchain::Validations::Validators::Inclusion
- Defined in:
- lib/toolchain/validations/validators/inclusion.rb
Overview
Validates the inclusion of values in an attribute. In the example, only ‘pending` and `dispatched` are allowed to be set.
Instance Attribute Summary
Attributes inherited from Base
#data, #errors, #key_path, #message, #object
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Toolchain::Validations::Validators::Base
Instance Method Details
#validate ⇒ Object
17 18 19 20 21 |
# File 'lib/toolchain/validations/validators/inclusion.rb', line 17 def validate if not_included? errors.add(key_path, || "is invalid") end end |