Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶ added in v0.11.0
func Diff(reference, candidate *Normalised) (differences []string)
Diff returns the paths at which two normalised payloads differ, without values. Both payloads are instances of the reference's declared type.
Types ¶
type Normalised ¶ added in v0.11.0
type Normalised struct {
// contains filtered or unexported fields
}
Normalised is one payload after every applicable normaliser has run.
func Raw ¶ added in v0.25.0
func Raw(payload any) *Normalised
Raw wraps an untyped payload that no normaliser applies to.
func (*Normalised) CanonicalJSON ¶ added in v0.14.0
func (n *Normalised) CanonicalJSON() ([]byte, error)
CanonicalJSON encodes the payload with sorted object keys, so structurally equal payloads encode identically. A removed root encodes as null.
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan binds JavaScript normaliser declarations to one declared schema. It is immutable after construction and safe to share across normalisations.
func NewPlan ¶
func NewPlan(loaded *schema.Schema, fields []javascript.FieldTarget, messages []schema.TypeRef) (*Plan, error)
NewPlan resolves and validates every declared normaliser target before activation.
func (*Plan) Normalise ¶ added in v0.11.0
func (p *Plan) Normalise( ctx context.Context, evaluator *javascript.Evaluator, root *schema.Type, side string, payload any, ) (*Normalised, error)
Normalise applies the plan to one decoded JSON payload of type root, which it takes ownership of and mutates. side only labels log records.