class ZohoHub::Validations::ValidatePicklist
Public Instance Methods
validate(options = {})
click to toggle source
# File lib/zoho_hub/validations/validate_picklist.rb, line 8 def validate(options = {}) value = record.send(field) return unless value list = options[: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