validation

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package validation contains shared structured validation errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONPointer

func JSONPointer(parts ...string) string

JSONPointer builds an RFC 6901 JSON Pointer from unescaped reference tokens.

func NewErrors

func NewErrors(scope Scope, violations []Violation) error

NewErrors returns a sorted aggregate error for violations. It returns nil when violations is empty.

Types

type Errors

type Errors struct {
	Violations []Violation `json:"violations"`
	// contains filtered or unexported fields
}

Errors contains every violation found in one validation phase.

func (*Errors) Error

func (e *Errors) Error() string

Error summarizes the contained validation violations.

type Rule

type Rule string

Rule identifies a stable validation rule.

const (
	RuleDecode              Rule = "decode"
	RuleSchema              Rule = "schema"
	RulePattern             Rule = "pattern"
	RuleSemVer              Rule = "semver"
	RuleVersionRange        Rule = "version-range"
	RuleSPDX                Rule = "spdx"
	RuleDuplicate           Rule = "duplicate"
	RuleNamespaceScope      Rule = "namespace-scope"
	RuleSelfDependency      Rule = "self-dependency"
	RuleRepositoryDirectory Rule = "repository-directory"
	RuleRepositoryURL       Rule = "repository-url"
	RuleSourcePath          Rule = "source-path"
	RuleTag                 Rule = "git-tag"
	RuleIdentity            Rule = "identity"
	RuleReference           Rule = "reference"
	RulePackagePath         Rule = "package-path"
	RuleSource              Rule = "source"
	RuleTimestamp           Rule = "timestamp"
)

type Scope

type Scope string

Scope identifies the subject of a validation failure.

const (
	// ScopeManifest identifies module manifest validation.
	ScopeManifest Scope = "manifest"
	// ScopeRegistry identifies Registry source document validation.
	ScopeRegistry Scope = "registry"
	// ScopeRegistryArtifact identifies Registry distribution artifact validation.
	ScopeRegistryArtifact Scope = "registry artifact"
	// ScopeAPICatalog identifies API Catalog artifact validation.
	ScopeAPICatalog Scope = "API catalog"
)

type Violation

type Violation struct {
	Path    string `json:"path"`
	Rule    Rule   `json:"rule"`
	Message string `json:"message"`
}

Violation describes one validation failure. Path is an RFC 6901 JSON Pointer; an empty path identifies the document root.

Jump to

Keyboard shortcuts

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