Documentation
¶
Overview ¶
Package validation supplies deterministic, payload-private validation results.
Index ¶
- Constants
- func CheckFold[R any](v Check, cs CheckCases[R]) R
- func CombinationEqual(a, b Combination) bool
- func CombinationEqualWith(a, b Combination, ov CombinationEqOverrides) bool
- func CombinationFold[R any](v Combination, cs CombinationCases[R]) R
- func StateEqual(a, b State) bool
- func StateEqualWith(a, b State, ov StateEqOverrides) bool
- func StateFold[R any](s State, cs StateCases[R]) R
- func StateName(state State) string
- type All
- type AtLeastOne
- type Budget
- type Check
- type CheckCases
- type Combination
- type CombinationCases
- type CombinationEqOverrides
- type Diagnostic
- type Indeterminate
- type Invalid
- type Limits
- type Meter
- type OnlyOne
- type Report
- type Satisfied
- type State
- type StateCases
- type StateEqOverrides
- type Undecided
- type Valid
- type Violated
Constants ¶
const DefaultClauseSteps uint64 = 100000
const DefaultTotalSteps uint64 = 1000000
Variables ¶
This section is empty.
Functions ¶
func CheckFold ¶
func CheckFold[R any](v Check, cs CheckCases[R]) R
CheckFold reduces Check by one-level case analysis.
func CombinationEqual ¶
func CombinationEqual(a, b Combination) bool
CombinationEqual reports structural equality of a and b.
func CombinationEqualWith ¶
func CombinationEqualWith(a, b Combination, ov CombinationEqOverrides) bool
CombinationEqualWith reports structural equality of a and b under ov.
func CombinationFold ¶
func CombinationFold[R any](v Combination, cs CombinationCases[R]) R
CombinationFold reduces Combination by one-level case analysis.
func StateEqual ¶
StateEqual reports structural equality of a and b.
func StateEqualWith ¶
func StateEqualWith(a, b State, ov StateEqOverrides) bool
StateEqualWith reports structural equality of a and b under ov.
func StateFold ¶
func StateFold[R any](s State, cs StateCases[R]) R
StateFold reduces State by one-level case analysis.
Types ¶
type AtLeastOne ¶
type AtLeastOne struct{}
type Budget ¶
type Budget struct {
// contains filtered or unexported fields
}
Budget belongs to one validation execution. It is not shared across threads. Each clause has an independent meter and draws from this common total.
func (*Budget) BeginClause ¶
BeginClause accepts an optional schema-declared per-where override. A caller cap remains effective even when the schema overrides its default clause cap.
func (*Budget) BeginStructure ¶
BeginStructure charges traversal/transfer work to the validation total, not to any individual where clause. Its allowance can never exceed that total.
type Check ¶
type Check interface {
// contains filtered or unexported methods
}
Check is one evaluated where clause, not one diagnostic per Boolean operand.
func Combine ¶
func Combine(mode Combination, checks []Check, detail Diagnostic) Check
type CheckCases ¶
type CheckCases[R any] struct { Satisfied func() R Violated func(Detail Diagnostic) R Undecided func(Detail Diagnostic) R }
CheckCases selects one handler per Check variant for CheckFold.
type Combination ¶
type Combination interface {
// contains filtered or unexported methods
}
Combination operates on already evaluated predicates. The expression evaluator separately controls short-circuiting and deterministic budgets.
type CombinationCases ¶
type CombinationCases[R any] struct { All func() R AtLeastOne func() R OnlyOne func() R }
CombinationCases selects one handler per Combination variant for CombinationFold.
type CombinationEqOverrides ¶
type CombinationEqOverrides struct {
All func(x, y All) (eq, handled bool)
AtLeastOne func(x, y AtLeastOne) (eq, handled bool)
OnlyOne func(x, y OnlyOne) (eq, handled bool)
}
CombinationEqOverrides carries optional per-variant hooks for CombinationEqualWith. A hook returning handled=false falls through to the derived comparison.
type Diagnostic ¶
type Diagnostic struct {
Code string `json:"code"`
Paths []string `json:"paths"`
Predicate string `json:"predicate"`
Message string `json:"message"`
}
Diagnostic deliberately has no payload field. A caller must explicitly implement the schema's opt-in message expression to include a payload value.
type Indeterminate ¶
type Indeterminate struct{}
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
func (*Meter) Nested ¶
Nested gives a refinement invoked during another predicate its own local limit while charging every enclosing meter. It cannot reset/relax a caller's allowance. Failure exhausts only this scope, leaving cheaper enclosing work possible when the enclosing budget still has room.
type Report ¶
type Report struct {
// contains filtered or unexported fields
}
Report is immutable to callers. Accessors copy diagnostics and nested paths.
func Collect ¶
Collect aggregates independent clauses without discarding a known violation when another predicate cannot finish. Input order is diagnostic order.
func MergeReports ¶
MergeReports combines independently produced reports without losing either diagnostics or an incomplete result. Invalid dominates indeterminate, just as Collect does for individual checks.
func (Report) Diagnostics ¶
func (r Report) Diagnostics() []Diagnostic
func (Report) Incomplete ¶
func (Report) MarshalJSON ¶
type State ¶
type State interface {
// contains filtered or unexported methods
}
State has three distinct outcomes. Invalid dominates unknown when aggregating separate where clauses, while predicate combinators have their own truth rules.
type StateCases ¶
type StateCases[R any] struct { Valid func() R Invalid func() R Indeterminate func() R }
StateCases selects one handler per State variant for StateFold.
type StateEqOverrides ¶
type StateEqOverrides struct {
Valid func(x, y Valid) (eq, handled bool)
Invalid func(x, y Invalid) (eq, handled bool)
Indeterminate func(x, y Indeterminate) (eq, handled bool)
}
StateEqOverrides carries optional per-variant hooks for StateEqualWith. A hook returning handled=false falls through to the derived comparison.
type Undecided ¶
type Undecided struct {
Detail Diagnostic
}
type Violated ¶
type Violated struct {
Detail Diagnostic
}