def errors
      errs = []

      # Make sure that every field is filled out
      self.class.fields.except(:project_id).each_with_object({}) do |(field_name, field_options), h|
        if options[field_name].blank?
          errs << "#{field_options[:label]} must be present"
        end
      end

      # We can only perform the other tests if the necessary values are at least present
      return {:base => errs.to_sentence} unless errs.size.zero?

      # Check if the given endpoint actually exists
      unless gitlab_endpoint_exists?(options[:endpoint])
        errs << 'No Gitlab installation was found under the given URL'
        return {:base => errs.to_sentence}
      end

      # Check if a user by the given token exists
      unless gitlab_user_exists?(options[:endpoint], options[:api_token])
        errs << 'No user with the given API token was found'
        return {:base => errs.to_sentence}
      end

      # Check if there is a project with the given name on the server
      unless gitlab_project_id(options[:endpoint], options[:api_token], options[:path_with_namespace])
        errs << "A project named '#{options[:path_with_namespace]}' could not be found on the server.
                 Please make sure to enter it exactly as it appears in your address bar in Gitlab (case sensitive)"
        return {:base => errs.to_sentence}
      end

      {}
    end
def errors
      errs = []

      # Make sure that every field is filled out
      self.class.fields.except(:project_id).each_with_object({}) do |(field_name, field_options), h|
        if options[field_name].blank?
          errs << "#{field_options[:label]} must be present"
        end
      end

      # We can only perform the other tests if the necessary values are at least present
      return {:base => errs.to_sentence} unless errs.size.zero?

      # Check if the given endpoint actually exists
      unless gitlab_endpoint_exists?(options[:endpoint])
        errs << 'No Gitlab installation was found under the given URL'
        return {:base => errs.to_sentence}
      end

      # Check if a user by the given token exists
      unless gitlab_user_exists?(options[:endpoint], options[:api_token])
        errs << 'No user with the given API token was found'
        return {:base => errs.to_sentence}
      end

      # Check if there is a project with the given name on the server
      unless gitlab_project_id(options[:endpoint], options[:api_token], options[:path_with_namespace])
        errs << "A project named '#{options[:path_with_namespace]}' could not be found on the server.
                 Please make sure to enter it exactly as it appears in your address bar in Gitlab (case sensitive)"
        return {:base => errs.to_sentence}
      end

      {}
    end
Called to validate user input. Just return a hash of errors if there are any