Skip to content

Instantly share code, notes, and snippets.

@isterin
Created December 13, 2010 23:12
Show Gist options
  • Save isterin/739773 to your computer and use it in GitHub Desktop.
Save isterin/739773 to your computer and use it in GitHub Desktop.
class RawEachValidator < ActiveModel::EachValidator
def validate(record)
attributes.each do |attribute|
raw_value = record.send("#{attribute}_before_type_cast") || record.read_attribute_for_validation(attribute)
self.validate_each(record, attribute, raw_value)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment