Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureRootWrappedBody ¶
EnsureRootWrappedBody returns body wrapped as ["root", {}, ...body] when the input is not already root-rooted. Returns the input unchanged when:
- body is empty
- body[0] is the literal string "root"
notes is non-empty only when wrapping was applied.
The function does not mutate its input.
func NormalizeJsonMLBody ¶
NormalizeJsonMLBody returns a deep-cloned body with safe auto-fixes applied, plus human-readable notes describing every change.
notes is empty when no fix was needed. fixed is the parsed JSON-friendly payload ready to be marshaled.
func NormalizeJsonMLNode ¶
NormalizeJsonMLNode normalizes a single block node (used by `doc block insert/update --format jsonml --element <node>`).
Types ¶
type JsonMLValidationResult ¶
JsonMLValidationResult holds errors and warnings from validation.
func ValidateJsonMLBodyV2 ¶
func ValidateJsonMLBodyV2(body []any) *JsonMLValidationResult
ValidateJsonMLBodyV2 validates a JSONML body using schema-v2. Only type mismatches are errors; everything else is a warning.
func ValidateJsonMLNodeV2 ¶
func ValidateJsonMLNodeV2(node any) *JsonMLValidationResult
ValidateJsonMLNodeV2 validates a single JSONML node using schema-v2.
func (*JsonMLValidationResult) HasErrors ¶
func (r *JsonMLValidationResult) HasErrors() bool
HasErrors returns true if there are blocking errors.
func (*JsonMLValidationResult) Summary ¶
func (r *JsonMLValidationResult) Summary() string
Summary returns a human-readable report.
type SchemaV2 ¶
type SchemaV2 struct {
Version string `json:"_version"`
Description string `json:"_description"`
Tags map[string]*TagSchema `json:"tags"`
// contains filtered or unexported fields
}
SchemaV2 is the top-level schema structure.
func (*SchemaV2) IsKnownTag ¶
IsKnownTag returns true if the tag is declared in the schema.
func (*SchemaV2) TagSchemaFor ¶
TagSchemaFor returns the schema for a tag, or nil if unknown.
type TagSchema ¶
type TagSchema struct {
AllowedChildren []string `json:"allowed_children"`
Attrs map[string]TypeSpec `json:"attrs"`
// contains filtered or unexported fields
}
TagSchema defines the schema for a single JSONML tag.
func (*TagSchema) IsAllowedChild ¶
IsAllowedChild returns true if childTag is in the parent's allowed_children.
type TypeSpec ¶
type TypeSpec struct {
Type string `json:"type"` // string|number|boolean|array|object|any|enum|union
Min *float64 `json:"min,omitempty"` // for number
Max *float64 `json:"max,omitempty"` // for number
Values []string `json:"values,omitempty"` // for enum
Types []string `json:"types,omitempty"` // for union: pass silently
WarnTypes []string `json:"warn_types,omitempty"` // for union: match → warning (not error)
Fields map[string]TypeSpec `json:"fields,omitempty"` // for object (deep validation)
}
TypeSpec represents a type constraint for an attribute value. Parsed from the schema JSON's unified object format: { "type": "...", ... }