You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: git_repo_file_preview.go
    path of file: ./repos/portainer/api/http/handler/gitops
    
    the code of the file until where you have to start completion: package gitops

import (
	"errors"
	"fmt"
	"net/http"

	gittypes "github.com/portainer/portainer/api/git/types"
	httperror "github.com/portainer/portainer/pkg/libhttp/error"
	"github.com/portainer/portainer/pkg/libhttp/request"
	"github.com/portainer/por
    
func (payload *repositoryFilePreviewPayload) Validate(r *http.Request) error {
	if govalidator.IsNull(payload.Repository) || !govalidator.IsURL(payload.Repository) {
		return errors.New("invalid repository URL. Must correspond to a valid URL format")
	}

	if govalidator.IsNull(payload.Reference) {
		payload.Reference = "refs/heads/main"
	}

	if govalidator.IsNull(payload.TargetFile) {
		return errors.New("invalid target filename")
	}

	return nil
}