Class: ChefAPI::Validator::Required
- Defined in:
- lib/chef-api/validators/required.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #inspect, #key, #to_s
Constructor Details
This class inherits a constructor from ChefAPI::Validator::Base
Instance Method Details
#validate(resource) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/chef-api/validators/required.rb', line 3 def validate(resource) value = resource._attributes[attribute] if value.to_s.strip.empty? resource.errors.add(attribute, 'must be present') end end |