Skip to content

Commit

Permalink
Make validations based on authentication keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 15, 2009
1 parent b70b293 commit 6c46c09
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/devise/models/validatable.rb
Expand Up @@ -12,14 +12,18 @@ module Validatable

def self.included(base)
base.class_eval do
attribute = authentication_keys.first

validates_presence_of :email
validates_uniqueness_of :email, :allow_blank => true
validates_format_of :email, :with => EMAIL_REGEX, :allow_blank => true
validates_presence_of attribute
validates_uniqueness_of attribute, :allow_blank => true
validates_format_of attribute, :with => EMAIL_REGEX, :allow_blank => true,
:scope => authentication_keys[1..-1]

validates_presence_of :password, :if => :password_required?
validates_confirmation_of :password, :if => :password_required?
validates_length_of :password, :within => 6..20, :allow_blank => true, :if => :password_required?
with_options :if => :password_required? do |v|
v.validates_presence_of :password
v.validates_confirmation_of :password
v.validates_length_of :password, :within => 6..20, :allow_blank => true
end
end
end

Expand Down

0 comments on commit 6c46c09

Please sign in to comment.