Skip to content

Instantly share code, notes, and snippets.

@jamesbrink
Created March 4, 2011 06:25
Show Gist options
  • Save jamesbrink/854260 to your computer and use it in GitHub Desktop.
Save jamesbrink/854260 to your computer and use it in GitHub Desktop.
simple validator
class DateOfBirthValidator < ActiveModel::Validator
def validate(record)
record.errors[:date_of_birth] << "Date Of Birth can not be set for a future date!"
end
private
def check(record)
(record.date_of_birth < Date.current)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment