class KafoWizards::Entries::PasswordEntry

Public Class Methods

entry_type() click to toggle source
# File lib/kafo_wizards/entries/password.rb, line 28
def self.entry_type
  :password
end
new(name, options={}) click to toggle source
Calls superclass method
# File lib/kafo_wizards/entries/password.rb, line 5
def initialize(name, options={})
  super(name, options)
  @confirmation_required = !!options.fetch(:confirmation_required, false)
end

Public Instance Methods

confirmation_required?() click to toggle source
# File lib/kafo_wizards/entries/password.rb, line 10
def confirmation_required?
  @confirmation_required
end
update(value) click to toggle source
# File lib/kafo_wizards/entries/password.rb, line 21
def update(value)
  if confirmation_required? && (value[:password] != value[:password_confirmation])
    raise KafoWizards::ValidationError.new("Password and confirmation do not match")
  end
  @value = validate(value[:password])
end
validate(value) click to toggle source
# File lib/kafo_wizards/entries/password.rb, line 14
def validate(value)
  if value.length < 8
    raise KafoWizards::ValidationError.new("Password must be at least 8 characters long")
  end
  value
end