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
- func Links(cfg *schema.Config, entries []Entry, exists func(string) bool, ...) []report.Finding
- func Page(cfg *schema.Config, coll schema.Collection, doc content.Document) []report.Finding
- func Schema(doc *load.Document, exists func(path string) bool) []report.Finding
- type Entry
- type Options
- type Result
Constants ¶
const ( ScopeSchema = "schema" ScopeContent = "content" ScopeLinks = "links" )
Scopes a run can be limited to.
Variables ¶
This section is empty.
Functions ¶
func Links ¶
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 ¶
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.
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.