constraint

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package constraint provides PSL constraint language for field relationships.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

type Constraint struct {
	Type       ConstraintType `json:"type"`
	Expression string         `json:"expression"`
	Fields     []string       `json:"fields"`
	Message    string         `json:"message"`
}

Constraint defines a field constraint.

type ConstraintBlock

type ConstraintBlock struct {
	Protocol    string       `json:"protocol"`
	Constraints []Constraint `json:"constraints"`
}

ConstraintBlock holds constraints for a protocol.

func NewBlock

func NewBlock(protocol string) *ConstraintBlock

NewBlock creates a new constraint block.

func (*ConstraintBlock) AddArithmetic

func (cb *ConstraintBlock) AddArithmetic(expr string, fields []string) *ConstraintBlock

AddArithmetic adds an arithmetic constraint.

func (*ConstraintBlock) AddReference

func (cb *ConstraintBlock) AddReference(expr string, fields []string) *ConstraintBlock

AddReference adds a reference constraint (e.g., checksum).

func (*ConstraintBlock) Describe

func (cb *ConstraintBlock) Describe() string

Describe returns a human-readable description.

func (*ConstraintBlock) Validate

func (cb *ConstraintBlock) Validate(values map[string]int64) []error

Validate validates field values against constraints.

type ConstraintType

type ConstraintType string

ConstraintType represents the type of constraint.

const (
	Arithmetic ConstraintType = "arithmetic"
	Reference  ConstraintType = "reference"
	Range      ConstraintType = "range_check"
	Custom     ConstraintType = "custom"
)

Jump to

Keyboard shortcuts

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