filter

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 4 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	OpIsNull
	OpNotNull
	OpNotLike // wire: "not-like" — added for ts-jsonapi parity
)

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