Method: Jamf::Extendable#validate_ea_value

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

#validate_ea_value(ea_name, value, validate_popup_choice, refresh) ⇒ Object

is the value being passed to set_ext_attr valid? Converts values as needed (e.g. strings to integers or Times)

If the EA is defined to hold a string, any value is accepted and converted with #to_s

Note: All EAs can be blank

Parameters:

  • name (String)

    the name of the extension attribute to set

  • value (String, Time, Integer)

    the new value for the extension attribute for this user

  • validate_popup_choice (Boolean)

    validate the new value against the E.A. definition. Defaults to true.

  • refresh (Boolean)

    Re-read the ext. attrib definition from the API, for popup validation.

Returns:

  • (Object)

    the possibly modified valid value



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/jamf/api/classic/api_objects/extendable.rb', line 244

def validate_ea_value(ea_name, value, validate_popup_choice, refresh)
  return Jamf::BLANK if value.to_s == Jamf::BLANK

  value =
    case ea_types[ea_name]
    when Jamf::ExtensionAttribute::DATA_TYPE_DATE
      Jamf.parse_time(value).to_s
    when *Jamf::ExtensionAttribute::NUMERIC_TYPES
      validate_integer_ea_value ea_name, value
    else
      value.to_s
    end # case

  validate_popup_value(ea_name, value, refresh) if validate_popup_choice

  value
end