Created
February 21, 2011 01:31
-
-
Save paulclip/836526 to your computer and use it in GitHub Desktop.
Rails 3 Custom Validators
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 PasswordValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
record.errors[attribute] << 'can''t equal name, username, or email' if [ record.name, record.username, record.email ].include?(value) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment