Module: Clearance::User::Validations
- Defined in:
- lib/clearance/user.rb
Class Method Summary collapse
-
.included(model) ⇒ Object
Hook for validations.
Class Method Details
.included(model) ⇒ Object
Hook for validations.
:email must be present, unique, formatted
If password is required, :password must be present, confirmed
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/clearance/user.rb', line 50 def self.included(model) model.class_eval do validates_presence_of :email, :unless => Proc.new { |user| !user.fbid.blank? } validates_uniqueness_of :email, :case_sensitive => false, :allow_blank => true validates_uniqueness_of :fbid, :unless => Proc.new { |user| user.fbid.blank? } validates_format_of :email, :with => %r{.+@.+\..+}, :allow_blank => true validates_presence_of :password, :unless => Proc.new { |user| !user.fbid.blank? or :password_optional? } validates_confirmation_of :password, :unless => Proc.new { |user| !user.fbid.blank? or :password_optional? } end end |