Method: Jamf::Extendable#validate_popup_value

Defined in:
lib/jamf/api/classic/api_objects/extendable.rb

#validate_popup_value(ea_name, value, refresh) ⇒ Object

Raise an error if the named EA has a popup menu, but the provided value isn’t one of the menu items



276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/jamf/api/classic/api_objects/extendable.rb', line 276

def validate_popup_value(ea_name, value, refresh)
  # get the ea def. instance from the api cache, or the api
  cnx.c_ext_attr_definition_cache[self.class] ||= {}
  cnx.c_ext_attr_definition_cache[self.class][ea_name] = nil if refresh
  cnx.c_ext_attr_definition_cache[self.class][ea_name] ||= self.class::EXT_ATTRIB_CLASS.fetch name: ea_name, cnx: cnx

  ea_def = cnx.c_ext_attr_definition_cache[self.class][ea_name]
  return unless ea_def.from_popup_menu?

  return if ea_def.popup_choices.include? value.to_s

  raise Jamf::UnsupportedError, "The value for #{ea_name} must be one of: '#{ea_def.popup_choices.join("' '")}'"
end