module Negroni::Models::Validatable
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.
## Options
Validatable
adds the following options to devise_for:
* `email_regexp`: the regular expression used to validate e-mails * `password_length`: a range expressing password length. Default: 8..72
Public Class Methods
required_fields(_klass = nil)
click to toggle source
Required fields for :validatable
# File lib/negroni/models/validatable.rb, line 21 def self.required_fields(_klass = nil) [] end
Protected Instance Methods
email_required?()
click to toggle source
Override this method if an email is not required for your model
# File lib/negroni/models/validatable.rb, line 53 def email_required? true end
password_required?()
click to toggle source
# File lib/negroni/models/validatable.rb, line 48 def password_required? !persisted? || !password.nil? || !password_confirmation.nil? end