class UsersArrayValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, valueArray)
    unless valueArray.empty?
      res = begin
        users = Devops::Model::User.find(valueArray)#.projection({'_id' => true})
        valueArray - users.map{|u| u.id}
      rescue Mongoid::Errors::DocumentNotFound
        valueArray
      end
      unless res.empty?
        record.errors.add attribute, (options[:message] || "User(s) '#{res.join("', '")}' not found")
      end
    end
  end

end
