Documentation
¶
Overview ¶
Package schema implements a classmesh.Stage that validates a structured record's decoded Fields against a declared shape. It classifies records that violate the schema into a quarantine category, with a reason per violation, and escalates valid records with ErrUnclassified, so it sits in front of the real classification stages and routes malformed input aside.
Index ¶
Constants ¶
const Name = "schema"
Name identifies this stage in classifications, stats, and logs.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
Field constrains one value, addressed by a path the fieldpath package understands. A Required field must be present; unless Type is Any, a present value must hold that type.
type Stage ¶
type Stage struct {
// contains filtered or unexported fields
}
Stage validates records against a set of Field constraints. Schemas whose paths share prefixes are classified through a prefix trie that walks each shared prefix once per record; the rest use a flat per-field walk, which the trie cannot beat when there is no prefix to share.
func New ¶
New compiles the field constraints. category names where violating records go; at least one field is required and every field needs a path. A trie is built only when it would save prefix descents over the flat walk.