Documentation
¶
Overview ¶
Package yamlschema validates YAML documents against a JSON Schema and reports each problem with its file:line:column.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeAt ¶
NodeAt returns the YAML node at loc, or the deepest node that exists. With keyNode, a mapping entry's key node is returned instead of its value.
func SortProblems ¶
func SortProblems(problems []Problem)
SortProblems orders problems by line, then column, keeping the order of equal positions.
func ToJSONValue ¶
ToJSONValue converts a decoded YAML value into the form the validator expects.
Types ¶
type Document ¶
type Document struct {
Data any // decoded value; an empty file decodes to an empty map
Root *yaml.Node // for positions, see [NodeAt]
}
Document is a parsed YAML file.
type Leaf ¶
type Leaf struct {
Loc []string
Message string
KeyNode bool // report the key's position, not the value's
}
Leaf is one schema violation at an instance location.
type Problem ¶
type Problem struct {
Origin string // file path, "env NAME" or "flag --x"
Line int // 0 when there is no position
Column int
Key string
Message string
}
Problem is one validation error and where it is.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is a compiled JSON Schema that keeps its raw form for type lookups.
func (*Schema) Parse ¶
Parse decodes the YAML in b and validates it. Syntax errors and schema violations come back as problems with origin and position; the error is only for failures of the validator itself.