Class: Formidable::Validations::ValidateLength
- Inherits:
-
Validation
- Object
- Validation
- Formidable::Validations::ValidateLength
- Defined in:
- lib/formidable/validations/length.rb
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Attributes inherited from Validation
Instance Method Summary collapse
-
#initialize(element, length) ⇒ ValidateLength
constructor
A new instance of ValidateLength.
-
#message ⇒ Object
TODO: user can set message.
- #valid? ⇒ Boolean
Methods inherited from Validation
Constructor Details
#initialize(element, length) ⇒ ValidateLength
Returns a new instance of ValidateLength.
12 13 14 15 |
# File 'lib/formidable/validations/length.rb', line 12 def initialize(element, length) super(element) @length = length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
11 12 13 |
# File 'lib/formidable/validations/length.rb', line 11 def length @length end |
Instance Method Details
#message ⇒ Object
TODO: user can set message
21 22 23 24 25 26 27 |
# File 'lib/formidable/validations/length.rb', line 21 def # TODO: user can set message if length.respond_to?(:first) else end end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/formidable/validations/length.rb', line 17 def valid? length === element.length end |