Class: KafoWizards::Entries::PasswordEntry
Instance Attribute Summary
#default_value, #description, #label, #name, #parent, #post_hook, #pre_hook, #validators, #value
Class Method Summary
collapse
Instance Method Summary
collapse
#call_post_hook, #call_pre_hook, descendants, #display_type, inherited, #required?
Constructor Details
#initialize(name, options = {}) ⇒ PasswordEntry
Returns a new instance of PasswordEntry.
5
6
7
8
|
# File 'lib/kafo_wizards/entries/password.rb', line 5
def initialize(name, options={})
super(name, options)
@confirmation_required = !!options.fetch(:confirmation_required, false)
end
|
Class Method Details
.entry_type ⇒ Object
28
29
30
|
# File 'lib/kafo_wizards/entries/password.rb', line 28
def self.entry_type
:password
end
|
Instance Method Details
#confirmation_required? ⇒ Boolean
10
11
12
|
# File 'lib/kafo_wizards/entries/password.rb', line 10
def confirmation_required?
@confirmation_required
end
|
#update(value) ⇒ Object
21
22
23
24
25
26
|
# 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) ⇒ Object
14
15
16
17
18
19
|
# 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
|