Module: Devision::Models::Validatable

Defined in:
lib/devision/models/validatable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/devision/models/validatable.rb', line 10

def self.included(base)
  base.extend(ClassMethods)
  base.class_eval do
    validates_presence_of :email, if: :email_required?
    validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
    validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?

    validates_presence_of :password, if: :password_required?
    validates_confirmation_of :password, if: :password_required?
    validates_length_of :password, within: password_length, allow_blank: true
  end
end

.required_fields(klass) ⇒ Object



6
7
8
# File 'lib/devision/models/validatable.rb', line 6

def self.required_fields(klass)
  []
end