lib/jamf/validate.rb in ruby-jss-2.1.1 vs lib/jamf/validate.rb in ruby-jss-3.0.0b1

- old
+ new

@@ -96,10 +96,12 @@ # # @param cnx [Jamf::Connection] The api connection to use for validation # # @return [Object] the validated unique value # - def self.doesnt_already_exist(klass, identifier, val, msg: nil, api: Jamf.cnx) + def self.doesnt_already_exist(klass, identifier, val, msg: nil, api: nil, cnx: Jamf.cnx) + cnx = api if api + return val unless klass.all(:refresh, cnx: cnx).map { |i| i[identifier] }.include? val key = klass.real_lookup_key identifier # use map_all_ids_to cuz it works with any identifer, even non-existing