Module: BlueLightSpecial::User::Validations

Defined in:
lib/blue_light_special/user.rb

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object

Hook for validations.

:email must be present, unique, formatted

If password is required, :password must be present, confirmed



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/blue_light_special/user.rb', line 52

def self.included(model)
  model.class_eval do
    validates_presence_of     :email, :unless => :email_optional?
    validates_uniqueness_of   :email, :case_sensitive => false, :allow_blank => true
    validates_format_of       :email, :with => %r{.+@.+\..+}, :allow_blank => true

    validates_presence_of     :password, :unless => :password_optional?
    validates_confirmation_of :password, :unless => :password_optional?
    
    validates_presence_of     :first_name, :last_name
  end
end