Help us shape the future of Go! Take the 2026 Go Developer Survey

validate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package validate checks AI Catalog documents against the specification and detects their conformance level (Minimal, Discoverable, Trusted).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code added in v0.3.0

type Code string

Code is a stable identifier for a kind of diagnostic. Match on it rather than on the message text.

const (
	CodeSpecVersion        Code = "spec-version"
	CodeHostMember         Code = "host-member-missing"
	CodeEntryMember        Code = "entry-member-missing"
	CodeEntryArtifact      Code = "entry-artifact-source"
	CodeEntryDuplicate     Code = "entry-duplicate"
	CodeEntryVersion       Code = "entry-version-conflict"
	CodeIdentifierNotURI   Code = "identifier-not-uri"
	CodeTimestamp          Code = "timestamp-invalid"
	CodePublisherMember    Code = "publisher-member-missing"
	CodeExtensionKey       Code = "extension-key-invalid"
	CodeNestedDepth        Code = "nested-depth-exceeded"
	CodeNestedInvalid      Code = "nested-catalog-invalid"
	CodeDigestInvalid      Code = "digest-invalid"
	CodeSignatureForm      Code = "signature-form"
	CodeSignatureMalformed Code = "signature-malformed"
	CodeSignatureAlgorithm Code = "signature-algorithm-forbidden"
	CodeSignatureB64       Code = "signature-b64"
	CodeSignatureUnlisted  Code = "signature-algorithm-unlisted"
)

Catalog, host and entry rules.

const (
	CodeManifestIdentity     Code = "manifest-identity-missing"
	CodeManifestIdentityURI  Code = "manifest-identity-not-uri"
	CodeManifestEmpty        Code = "manifest-not-substantive"
	CodeManifestSignedMember Code = "manifest-member-missing"
	CodeManifestExpired      Code = "manifest-expired"
	CodeSubjectMember        Code = "subject-member-missing"
	CodeSubjectMismatch      Code = "subject-mismatch"
	CodeTrustSchemaMember    Code = "trust-schema-member-missing"
	CodeAttestationMember    Code = "attestation-member-missing"
	CodeProvenanceMember     Code = "provenance-member-missing"
)

Trust manifest rules.

const (
	CodeProfileIdentifier Code = "profile-identifier"
	CodeProfileIdentity   Code = "profile-identity"
	CodeProfileType       Code = "profile-identity-type"
	CodeProfileAlgorithm  Code = "profile-algorithm"
	CodeProfileKeyID      Code = "profile-key-id"
	CodeProfileHeader     Code = "profile-header-member"
)

did:web Publisher Profile rules. They are warnings that keep the catalog from Trusted.

type ConformanceLevel

type ConformanceLevel int

ConformanceLevel is the AI Catalog conformance level a document satisfies.

const (
	// Minimal is a document with errors, or without a host.
	Minimal ConformanceLevel = iota

	// Discoverable is a valid document with a host.
	Discoverable

	// Trusted is a Discoverable document in which every root entry trust
	// manifest is signed, bound to its entry, unexpired and conforms to the
	// did:web Publisher Profile. Signatures are not verified.
	Trusted
)

func (ConformanceLevel) String

func (l ConformanceLevel) String() string

String returns the lowercase name of the conformance level.

type Diagnostic

type Diagnostic struct {
	Code    Code
	Path    string
	Message string
}

Diagnostic is a single validation error or warning.

type Option added in v0.3.0

type Option func(*config)

Option customizes Validate.

func WithClock added in v0.3.0

func WithClock(now func() time.Time) Option

WithClock sets the clock used to decide whether a trust manifest has expired.

func WithMaxNestingDepth added in v0.3.0

func WithMaxNestingDepth(depth int) Option

WithMaxNestingDepth sets how deeply catalogs may nest. The default is 4.

type Result

type Result struct {
	// IsValid reports whether the document has no validation errors.
	IsValid bool

	// ConformanceLevel is the highest level the document satisfies.
	ConformanceLevel ConformanceLevel

	// Errors are conformance-breaking problems.
	Errors []Diagnostic

	// Warnings are advisory problems, including did:web profile violations.
	Warnings []Diagnostic
}

Result is the outcome of validating an AI Catalog document.

func Source

func Source(ctx context.Context, c catalog.Source, opts ...Option) (Result, error)

Source loads the AI Catalog document behind c and validates it, for callers holding a catalog.Source rather than an already-parsed document.

func Validate

func Validate(c *catalog.AICatalog, opts ...Option) Result

Validate checks the catalog against the AI Catalog specification and returns the diagnostics and the detected conformance level.

Jump to

Keyboard shortcuts

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