value

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package value defines the registry for typed captures such as "{{ id:vlan }}". Each type has a match pattern and an optional Check function. The built-in types are word, rest, and uint. Word is the default for untyped captures. Schemas must register platform-specific types.

Register embeds a pattern in a larger expression, so it rejects anchors and capturing groups: an anchored pattern compiles but then matches nothing, and the schema layer addresses captures by name. Use the (?:...) form for groups.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps type names to Types; the zero Registry gains the built-ins on first Register.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns a registry preloaded with the built-in value types.

func (*Registry) Get

func (r *Registry) Get(name string) (Type, bool)

Get returns the named type and whether it is registered.

func (*Registry) Register

func (r *Registry) Register(t Type) error

Register adds or replaces a valid type; callers must register all types before compiling schema templates.

type Type

type Type struct {
	Name    string
	Pattern string
	Check   func(s string) error // nil => the pattern alone fully validates the value
}

Type defines an unanchored, non-capturing match pattern and optional validation for a captured string.

Jump to

Keyboard shortcuts

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