Class: ZohoHub::Validations::ValidatePicklist
- Inherits:
-
BaseValidation
- Object
- BaseValidation
- ZohoHub::Validations::ValidatePicklist
- Defined in:
- lib/zoho_hub/validations/validate_picklist.rb
Instance Attribute Summary
Attributes inherited from BaseValidation
Instance Method Summary collapse
Methods inherited from BaseValidation
Constructor Details
This class inherits a constructor from ZohoHub::Validations::BaseValidation
Instance Method Details
#validate(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/zoho_hub/validations/validate_picklist.rb', line 8 def validate( = {}) value = record.send(field) return unless value list = [:list].map { |option| option[:actual_value] } return if list.include?(value) msg = "has an invalid value `#{value}`. Accepted values: #{list.join(', ')}" record.add_error(field, msg) end |