Class: Exocora::ValidationOfPresence
- Inherits:
-
Validation
- Object
- Validation
- Exocora::ValidationOfPresence
- Defined in:
- lib/exocora/validation.rb
Overview
ValidationOfPresence is a special validation which ensures its value is both present and non-empty.
Constant Summary collapse
- DEFAULT_MESSAGE =
'must be present'
Instance Attribute Summary
Attributes inherited from Validation
Instance Method Summary collapse
-
#initialize(message = DEFAULT_MESSAGE) ⇒ ValidationOfPresence
constructor
A new instance of ValidationOfPresence.
- #validate(value = nil) ⇒ Object
Methods inherited from Validation
Constructor Details
#initialize(message = DEFAULT_MESSAGE) ⇒ ValidationOfPresence
Returns a new instance of ValidationOfPresence.
81 82 83 |
# File 'lib/exocora/validation.rb', line 81 def initialize(=DEFAULT_MESSAGE) = end |
Instance Method Details
#validate(value = nil) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/exocora/validation.rb', line 85 def validate(value = nil) if value.nil? or (value.respond_to? :empty? and value.empty?) raise ValidationError.new(value, ) else value end end |