Class: Field::Password

Inherits:
Base
  • Object
show all
Defined in:
lib/field/password.rb

Instance Attribute Summary

Attributes inherited from Base

#fieldset, #form, #name, #value

Instance Method Summary collapse

Methods inherited from Base

#attribute, #form?, #initialize

Constructor Details

This class inherits a constructor from Field::Base

Instance Method Details

#add_attributes(klass, options) ⇒ Object



3
4
5
6
7
# File 'lib/field/password.rb', line 3

def add_attributes(klass, options)
  klass.attribute :"#{name}_confirmation", String

  super
end

#add_validations(klass, options) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/field/password.rb', line 9

def add_validations(klass, options)
  klass.validates name, presence: true, if: ->(f){ !f.to_param }
  klass.validates name, confirmation: true, if: ->(f){ !f.to_param }
  klass.validates name, length: { minimum: 5, maximum: 15 }, allow_blank: true

  super
end

#outputObject



17
18
19
# File 'lib/field/password.rb', line 17

def output
  nil
end