Method: JSS::Extendable#validate_ea_value

Defined in:
lib/jss/api_object/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



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/jss/api_object/extendable.rb', line 262

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

  value =
    case ea_types[ea_name]
    when JSS::ExtensionAttribute::DATA_TYPE_DATE
      JSS.parse_datetime(value).to_s
    when *JSS::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