validators

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Repository validation errors
	ErrInvalidRepositoryURL = errors.New("invalid repository URL")
	ErrInvalidSubfolderPath = errors.New("invalid subfolder path")

	// Package validation errors
	ErrPackageNameHasSpaces  = errors.New("package name cannot contain spaces")
	ErrReservedVersionString = errors.New("version string 'latest' is reserved and cannot be used")
	ErrVersionLooksLikeRange = errors.New("version must be a specific version, not a range")

	// Remote validation errors
	ErrInvalidRemoteURL = errors.New("invalid remote URL")

	// Registry validation errors
	ErrUnsupportedRegistryBaseURL   = errors.New("unsupported registry base URL")
	ErrMismatchedRegistryTypeAndURL = errors.New("registry type and base URL do not match")

	// Argument validation errors
	ErrNamedArgumentNameRequired     = errors.New("named argument name is required")
	ErrInvalidNamedArgumentName      = errors.New("invalid named argument name format")
	ErrArgumentValueStartsWithName   = errors.New("argument value cannot start with the argument name")
	ErrArgumentDefaultStartsWithName = errors.New("argument default cannot start with the argument name")

	// Server name validation errors
	ErrMultipleSlashesInServerName = errors.New("server name cannot contain multiple slashes")
	ErrInvalidServerNameFormat     = errors.New("server name format is invalid")
)

Error messages for validation

Functions

func HasNoSpaces

func HasNoSpaces(s string) bool

HasNoSpaces checks if a string contains no spaces

func IsValidRemoteURL

func IsValidRemoteURL(rawURL string) bool

IsValidRemoteURL checks if a URL is valid for remotes (stricter than packages - no localhost allowed)

func IsValidRepositoryURL

func IsValidRepositoryURL(source RepositorySource, url string) bool

IsValidRepositoryURL checks if the given URL is valid for the specified repository source

func IsValidSubfolderPath

func IsValidSubfolderPath(path string) bool

IsValidSubfolderPath checks if a subfolder path is valid

func IsValidTemplatedURL

func IsValidTemplatedURL(rawURL string, availableVariables []string, allowTemplates bool) bool

IsValidTemplatedURL validates a URL with template variables against available variables For packages: validates that template variables reference package arguments or environment variables For remotes: disallows template variables entirely

func IsValidURL

func IsValidURL(rawURL string) bool

IsValidURL checks if a URL is in valid format (basic structure validation)

func ValidatePackage

func ValidatePackage(ctx context.Context, pkg model.Package, serverName string) error

ValidatePackage validates that the package referenced in the server configuration is: 1. allowed on the official registry (based on registry base url); and 2. owned by the publisher, by checking for a matching server name in the package metadata

func ValidatePublishRequest

func ValidatePublishRequest(ctx context.Context, req apiv0.ServerJSON, cfg *config.Config) error

ValidatePublishRequest validates a complete publish request including extensions

func ValidateServerJSON

func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error

Types

type RepositorySource

type RepositorySource string

RepositorySource represents valid repository sources

const (
	SourceGitHub RepositorySource = "github"
	SourceGitLab RepositorySource = "gitlab"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL