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
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/clearance/user.rb', line 68 def self.included(model) model.class_eval do validates_presence_of :email validates_uniqueness_of :email, :case_sensitive => false validates_format_of :email, :with => %r{.+@.+\..+} validates_presence_of :password, :if => :password_required? validates_confirmation_of :password, :if => :password_required? end end |