Class: Toolchain::Validations::Validators::Presence
- Defined in:
- lib/toolchain/validations/validators/presence.rb
Overview
Validates the presence of an attribute. If the attribute is either ‘nil` or `“”` (empty String) it is considered invalid.
Instance Attribute Summary
Attributes inherited from Base
#data, #errors, #key_path, #message, #object
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Toolchain::Validations::Validators::Base
Instance Method Details
#validate ⇒ Object
15 16 17 |
# File 'lib/toolchain/validations/validators/presence.rb', line 15 def validate errors.add(key_path, || "can't be blank") if blank? end |