class Hashme::Validations::CastedAttributeValidator

Public Instance Methods

validate_each(document, attribute, value) click to toggle source
# File lib/hashme/validations/casted_attribute_validator.rb, line 5
def validate_each(document, attribute, value)
  is_array = value.is_a?(Array) || value.is_a?(CastedArray)
  values = is_array ? value : [value]
  return if values.collect {|attr| attr.nil? || attr.valid? }.all?
  document.errors.add(attribute)
end