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: api.go
    path of file: ./repos/grafana/pkg/infra/filestorage
    
    the code of the file until where you have to start completion: package filestorage

import (
	"context"
	"errors"
	"fmt"
	"path/filepath"
	"regexp"
	"strings"
	"time"
)

var (
	ErrRelativePath          = errors.New("path cant be relative")
	ErrNonCanonicalPath      = errors.New("path must be canonical")
	ErrPathTooLong           = errors.New("path is too long")
	ErrInvalidCharact
    
func ValidatePath(path string) error {
	if !strings.HasPrefix(path, Delimiter) {
		return ErrRelativePath
	}

	if path == Delimiter {
		return nil
	}

	if strings.HasSuffix(path, Delimiter) {
		return ErrPathEndsWithDelimiter
	}

	// apply `ToSlash` to replace OS-specific separators introduced by the Clean() function
	if filepath.ToSlash(filepath.Clean(path)) != path {
		return ErrNonCanonicalPath
	}

	if len(path) > maxPathLength {
		return ErrPathTooLong
	}

	for _, part := range strings.Split(strings.TrimPrefix(path, Delimiter), Delimiter) {
		if strings.TrimSpace(part) == "" {
			return ErrEmptyPathPart
		}

		if len(part) > maxPathPartLength {
			return ErrPathPartTooLong
		}
	}

	matches := pathRegex.MatchString(path)
	if !matches {
		return ErrInvalidCharacters
	}

	return nil
}