Module: Headstart::User::Validations
- Defined in:
- lib/headstart/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
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/headstart/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 validates_presence_of :first_name, :last_name, :if => :last_name_should_be_required? end end |