validator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgType

type ArgType int

ArgType represents the expected type of an argument.

const (
	AnyType ArgType = iota
	NumberType
	StringType
	BooleanType
	ArrayType
	ObjectType
	VariableType
)

Argument types for operator validation.

type CustomOperatorChecker added in v1.0.1

type CustomOperatorChecker func(operatorName string) bool

CustomOperatorChecker is a function that checks if a custom operator exists.

type OperatorSpec

type OperatorSpec struct {
	Name        string
	MinArgs     int
	MaxArgs     int
	ArgTypes    []ArgType
	Description string
}

OperatorSpec defines the specification for an operator.

type ValidationError

type ValidationError struct {
	Operator string
	Message  string
	Path     string
}

ValidationError represents a validation error with context.

func (ValidationError) Error

func (e ValidationError) Error() string

type Validator

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

Validator validates JSON Logic expressions.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new validator with all supported operators.

func (*Validator) GetSupportedOperators

func (v *Validator) GetSupportedOperators() []string

GetSupportedOperators returns a list of all supported operators.

func (*Validator) IsOperatorSupported

func (v *Validator) IsOperatorSupported(operator string) bool

IsOperatorSupported checks if an operator is supported.

func (*Validator) SetCustomOperatorChecker added in v1.0.1

func (v *Validator) SetCustomOperatorChecker(checker CustomOperatorChecker)

SetCustomOperatorChecker sets a function to check for custom operators. When set, unknown operators will be checked against this function before failing validation.

func (*Validator) Validate

func (v *Validator) Validate(logic interface{}) error

Validate validates a JSON Logic expression.

Jump to

Keyboard shortcuts

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