Documentation
¶
Overview ¶
Package validity helps you build fast and portable validation logic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Inputs = make(registry[Input]) Outputs = make(registry[Output]) // ErrPluginAlreadyRegistered is returned when a plugin ID is registered more than once. ErrPluginAlreadyRegistered = errors.New("plugin already registered") )
Inputs is the global registry of input plugins. Outputs is the global registry of output plugins.
Functions ¶
Types ¶
type Constraint ¶
type Constraint struct {
Kind Kind
Op string // for KindBound: "<=", "<", ">=", ">"
Int int64 // for KindBound
Values []any // for KindEnum: allowed values as native string/int64/float64
Raw cue.Value
}
Constraint is a single classified constraint on a Field.
type Field ¶
Field is a field within a Def.
func (Field) Constraints ¶
func (f Field) Constraints() []Constraint
Constraints returns the classified constraints on the field. Constraints the reading layer does not recognize are returned with Kind KindUnsupported and their Raw value intact, never dropped.
type IR ¶
IR is the intermediate representation passed between input and output plugins. The wrapped CUE value is the source of truth: the methods on IR and its child types are a classified view over it, and Raw is always available as an escape hatch for anything those methods do not cover.
func (IR) Definitions ¶
Definitions returns the top-level definitions in the IR.
type Kind ¶
type Kind int
Kind classifies a Constraint.
const ( // KindUnsupported marks a constraint the reading layer could not classify. // Its Raw value is preserved so callers can report or handle it explicitly // rather than silently dropping it. KindUnsupported Kind = iota // KindBound is a numeric comparison constraint. KindBound // KindNonZero requires the field's value to differ from its type's zero value. KindNonZero // KindEnum requires the field's value to be one of a fixed set. KindEnum )
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
validity
command
|
|
|
examples
|
|
|
input
|
|
|
cue
Package cue implements the cue input plugin.
|
Package cue implements the cue input plugin. |
|
validator
Package validator implements an input plugin that derives a CUE IR from go-playground/validator struct tags.
|
Package validator implements an input plugin that derives a CUE IR from go-playground/validator struct tags. |
|
output
|
|
|
cel
Package cel implements the CEL output plugin.
|
Package cel implements the CEL output plugin. |
|
cue
Package cue implements the CUE output plugin.
|
Package cue implements the CUE output plugin. |
|
golang
Package golang implements the golang output plugin.
|
Package golang implements the golang output plugin. |
|
Package runner provides the CLI entry point for validity.
|
Package runner provides the CLI entry point for validity. |