validate

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package validate runs the checks: the schema on its own, every content file against its collection, and the links between files. Site runs all of them over a file system; Schema, Page and Links are the pieces for callers that already hold the parts.

Index

Constants

View Source
const (
	ScopeSchema  = "schema"
	ScopeContent = "content"
	ScopeLinks   = "links"
)

Scopes a run can be limited to.

Variables

This section is empty.

Functions

func Links(cfg *schema.Config, entries []Entry, exists func(string) bool, sidecars []string) []report.Finding

Links checks the references between files: URL collisions, site links, assets, reference fields and orphaned sidecars. exists reports whether a repository path is a file; sidecars lists the sidecar files under `.norcube/cms/meta`.

func Page

func Page(cfg *schema.Config, coll schema.Collection, doc content.Document) []report.Finding

Page checks one content file against its collection: the editor's validators (required, shape, item type, array bounds, regex, length, number bounds, unique, custom) plus out-of-schema keys and an unexpected body. Findings for fields hidden by `hidden` or `visibleIf` are dropped, as the editor drops them.

func Schema

func Schema(doc *load.Document, exists func(path string) bool) []report.Finding

Schema checks a loaded configuration on its own: every field well formed, every reference resolvable, every knob in range, storages and the preview block consistent. exists answers whether a repository path is present, for the checks that look at files; nil skips them.

Types

type Entry

type Entry struct {
	Path       string
	Collection string
	URL        string
	Locale     string
	Title      string
	Keys       map[string]string
	// Routes is true when the collection derives URLs from the file.
	Routes bool
	// contains filtered or unexported fields
}

Entry is what the links checks know about one content file: the shape the content index stores.

type Options

type Options struct {
	// Only lists the scopes to run; empty means all three.
	Only []string
	// Collection limits content and links checks to one collection's
	// files.
	Collection string
	// Strict promotes every warning to an error.
	Strict bool
}

Options limit a run.

type Result

type Result struct {
	Findings []report.Finding `json:"findings"`
	// Files is the number of content files checked.
	Files int `json:"files"`
	// SchemaFiles is the number of schema files loaded.
	SchemaFiles int `json:"schemaFiles"`
	Errors      int `json:"errors"`
	Warnings    int `json:"warnings"`
	// Config is the loaded configuration, for callers that want it.
	Config *schema.Config `json:"-"`
}

Result is what a run found.

func Site

func Site(fsys fs.FS, opts Options) (*Result, error)

Site validates the site rooted at fsys. load.ErrNotASite is returned when the directory holds no CMS configuration; other errors are I/O.

Jump to

Keyboard shortcuts

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