filter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package filter provides a generic specification pattern implementation for filtering resources.

It defines interfaces for Filters and Specifications that can be used to build complex query criteria in a type-safe manner. It includes common validators and logical operators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyValid

func AnyValid(validators ...func(FieldFilter[any]) error) func(FieldFilter[any]) error

AnyValid returns a validator that passes if at least one of the validators passes

func NewFieldFilter

func NewFieldFilter[T any](op Operator, name string, val T) *fieldFilter[T]

func ValidateArrayOrSingleField

func ValidateArrayOrSingleField[T any](f FieldFilter[any]) error

func ValidateIntegerString

func ValidateIntegerString(f FieldFilter[any]) error

func ValidateNil

func ValidateNil(f FieldFilter[any]) error

func ValidateNotZero

func ValidateNotZero(f FieldFilter[any]) error

ValidateNotZero validates that a field filter's value is not a zero value

func ValidateTyped

func ValidateTyped[T any](f FieldFilter[any]) error

ValidateTyped validates that a field filter's value is of the specified type T

func ValidateUUID

func ValidateUUID(f FieldFilter[any]) error

func ValidateValOneOf

func ValidateValOneOf[T comparable](allowed ...T) func(FieldFilter[any]) error

ValidateValOneOf returns a validator that checks if the value is one of the allowed values

Types

type FieldFilter

type FieldFilter[T any] interface {
	Name() string
	Value() T
	Operator() Operator
}

type Operator

type Operator uint
const (
	OpUndefined Operator = iota
	OpEq
	OpNEq
	OpGT
	OpGTEq
	OpLT
	OpLTEq
	OpIn
	OpNotIn
	OpLike
	OpBetween
	OpContains
	OpContainsLike
	OpIs
	OpIsNot
)

func (Operator) String

func (op Operator) String() string

func (Operator) Valid

func (op Operator) Valid() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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