Class: Formidable::Validations::ValidatePresence
- Inherits:
-
Validation
- Object
- Validation
- Formidable::Validations::ValidatePresence
- Defined in:
- lib/formidable/validations/presence.rb
Instance Attribute Summary
Attributes inherited from Validation
Instance Method Summary collapse
-
#initialize(*args) ⇒ ValidatePresence
constructor
A new instance of ValidatePresence.
- #message ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Validation
Constructor Details
#initialize(*args) ⇒ ValidatePresence
Returns a new instance of ValidatePresence.
8 9 10 11 12 13 14 15 |
# File 'lib/formidable/validations/presence.rb', line 8 def initialize(*args) super(*args) # HTML 5 unless element.attributes.has_key?(:required) element.attributes[:required] = true end end |
Instance Method Details
#message ⇒ Object
21 22 23 |
# File 'lib/formidable/validations/presence.rb', line 21 def "can't be empty" end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/formidable/validations/presence.rb', line 17 def valid? ! element.cleaned_data.nil? end |