Skip to content

Instantly share code, notes, and snippets.

@paulclip
Created February 21, 2011 01:31
Show Gist options
  • Save paulclip/836526 to your computer and use it in GitHub Desktop.
Save paulclip/836526 to your computer and use it in GitHub Desktop.
Rails 3 Custom Validators
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