Validatable creates all needed validations for a user email and password. It’s optional, given you may want to create the validations by yourself. Automatically validate if the email is present, unique and its format is valid. Also tests presence of password, confirmation and length.
OptionsValidatable adds the following options to devise
:
* +email_regexp+: the regular expression used to validate e-mails;
* +password_length+: a range expressing password length. Defaults to 6..128.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapseAll validations used by this module.
[:validates_presence_of, :validates_uniqueness_of, :validates_format_of, :validates_confirmation_of, :validates_length_of].freeze
:nodoc:.
41 42 43 44 45 46 47 48
# File 'lib/devise/models/validatable.rb', line 41 def self.assert_validations_api!(base) unavailable_validations = VALIDATIONS.select { |v| !base.respond_to?(v) } unless unavailable_validations.empty? raise "Could not use :validatable module since #{base} does not respond " \ "to the following methods: #{unavailable_validations.to_sentence}." end end.included(base) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39
# File 'lib/devise/models/validatable.rb', line 26 def self.included(base) base.extend ClassMethods assert_validations_api!(base) base.class_eval do validates_presence_of :email, if: :email_required? validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :devise_will_save_change_to_email? validates_format_of :email, with: email_regexp, allow_blank: true, if: :devise_will_save_change_to_email? 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
22 23 24
# File 'lib/devise/models/validatable.rb', line 22 def self.required_fields(klass) [] end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4