Class: Veto::PresenceCheck
- Inherits:
-
AttributeCheck
- Object
- Check
- AttributeCheck
- Veto::PresenceCheck
- Defined in:
- lib/veto/checks/presence_check.rb
Instance Method Summary collapse
Methods inherited from AttributeCheck
Methods inherited from Check
Constructor Details
This class inherits a constructor from Veto::AttributeCheck
Instance Method Details
#check(attribute, value, errors, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/veto/checks/presence_check.rb', line 3 def check(attribute, value, errors, ={}) msg = .fetch(:message, :presence) on = .fetch(:on, attribute) v = value.is_a?(String) ? value.gsub(/\s+/, '') : value if v.nil? || v.respond_to?(:empty?) && v.empty? errors.add(on, msg) end end |