validatorgen

package
v0.0.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package validatorgen compiles validator functions from resolved schemas.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildComplexTypePlan added in v0.0.25

func BuildComplexTypePlan(sch *parser.Schema, registry *analysis.Registry) (*complextypeplan.Plan, error)

BuildComplexTypePlan precomputes shared complex-type artifacts for compile/build phases.

func BuiltinTypeNames

func BuiltinTypeNames() []model.TypeName

BuiltinTypeNames returns the deterministic builtin type compile order.

func CollectAttributeUses

func CollectAttributeUses(schema *parser.Schema, ct *model.ComplexType) ([]*model.AttributeDecl, *model.AnyAttribute, error)

CollectAttributeUses resolves effective attribute uses and wildcard. It follows complex-type derivation from base to leaf in deterministic order.

Types

type CompiledValidators

type CompiledValidators struct {
	TypeValidators     map[ids.TypeID]runtime.ValidatorID
	ValidatorByType    map[model.Type]runtime.ValidatorID
	SimpleContentTypes map[*model.ComplexType]model.Type
	ComplexTypes       *complextypeplan.Plan
	Validators         runtime.ValidatorsBundle
	Enums              runtime.EnumTable
	Facets             []runtime.FacetInstr
	Patterns           []runtime.Pattern
	Values             runtime.ValueBlob
	// contains filtered or unexported fields
}

CompiledValidators contains all runtime validator artifacts generated from a schema.

func Compile

func Compile(sch *parser.Schema, registry *analysis.Registry) (*CompiledValidators, error)

Compile builds validators and value tables for the prepared schema.

func CompileWithComplexTypePlan added in v0.0.25

func CompileWithComplexTypePlan(
	sch *parser.Schema,
	registry *analysis.Registry,
	complexTypes *complextypeplan.Plan,
) (*CompiledValidators, error)

CompileWithComplexTypePlan compiles validators, optionally reusing a precomputed complex-type plan.

func (*CompiledValidators) AttrUseDefault added in v0.0.25

func (c *CompiledValidators) AttrUseDefault(attr *model.AttributeDecl) (DefaultFixedValue, bool)

AttrUseDefault returns the compiled default value for a specific attribute use.

func (*CompiledValidators) AttrUseFixed added in v0.0.25

func (c *CompiledValidators) AttrUseFixed(attr *model.AttributeDecl) (DefaultFixedValue, bool)

AttrUseFixed returns the compiled fixed value for a specific attribute use.

func (*CompiledValidators) AttributeDefault added in v0.0.25

func (c *CompiledValidators) AttributeDefault(id ids.AttrID) (DefaultFixedValue, bool)

AttributeDefault returns the compiled default value for an attribute declaration.

func (*CompiledValidators) AttributeFixed added in v0.0.25

func (c *CompiledValidators) AttributeFixed(id ids.AttrID) (DefaultFixedValue, bool)

AttributeFixed returns the compiled fixed value for an attribute declaration.

func (*CompiledValidators) ElementDefault added in v0.0.25

func (c *CompiledValidators) ElementDefault(id ids.ElemID) (DefaultFixedValue, bool)

ElementDefault returns the compiled default value for a global/local element.

func (*CompiledValidators) ElementFixed added in v0.0.25

func (c *CompiledValidators) ElementFixed(id ids.ElemID) (DefaultFixedValue, bool)

ElementFixed returns the compiled fixed value for a global/local element.

func (*CompiledValidators) ValidatorForType added in v0.0.25

func (c *CompiledValidators) ValidatorForType(typ model.Type) (runtime.ValidatorID, bool)

ValidatorForType returns the validator ID for a type when available.

type DefaultFixedValue

type DefaultFixedValue struct {
	Key    runtime.ValueKeyRef
	Ref    runtime.ValueRef
	Member runtime.ValidatorID
}

DefaultFixedValue stores canonical default/fixed metadata for runtime tables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL