Created
March 4, 2011 06:25
-
-
Save jamesbrink/854260 to your computer and use it in GitHub Desktop.
simple validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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