Method: Jamf::OAPIObject.validate_attr
- Defined in:
- lib/jamf/api/jamf_pro/base_classes/oapi_object.rb
.validate_attr(attr_name, value) ⇒ Object
Used by auto-generated setters and .create to validate new values.
returns a valid value or raises an exception
This method only validates single values. When called from multi-value setters, it is used for each value individually.
324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/jamf/api/jamf_pro/base_classes/oapi_object.rb', line 324 def self.validate_attr(attr_name, value) attr_def = self::OAPI_PROPERTIES[attr_name] raise ArgumentError, "Unknown attribute: #{attr_name} for #{self} objects" unless attr_def # validate the value based on the OAPI definition. Jamf::Validate.oapi_attr value, attr_def: attr_def, attr_name: attr_name # if this is an identifier, it must be unique # TODO: move this to colloection resouce code # Jamf::Validate.doesnt_exist(value, self, attr_name, cnx: cnx) if attr_def[:identifier] && superclass == Jamf::CollectionResource end |