Class: Bodhi::IsNotBlankValidator
- Defined in:
- lib/bodhi-slam/validators/blank.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ IsNotBlankValidator
constructor
A new instance of IsNotBlankValidator.
- #to_options ⇒ Object
- #validate(record, attribute, value) ⇒ Object
Methods inherited from Validator
constantize, #to_sym, #underscore
Constructor Details
#initialize(value) ⇒ IsNotBlankValidator
Returns a new instance of IsNotBlankValidator.
4 |
# File 'lib/bodhi-slam/validators/blank.rb', line 4 def initialize(value); end |
Instance Method Details
#to_options ⇒ Object
20 21 22 |
# File 'lib/bodhi-slam/validators/blank.rb', line 20 def {self.to_sym => true} end |
#validate(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bodhi-slam/validators/blank.rb', line 6 def validate(record, attribute, value) unless value.nil? if value.is_a?(Array) unless value.empty? record.errors.add(attribute, "must not contain blank Strings") unless value.delete_if{ |v| !v.empty? }.empty? end else record.errors.add(attribute, "can not be blank") if value.empty? end end end |