filter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: ISC Imports: 5 Imported by: 0

Documentation

Overview

Package filter provides filtering functionality for MaxMind database queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedOperators

func SupportedOperators() []string

SupportedOperators returns the list of supported filter operators.

func Validate

func Validate(filters []Filter) error

Validate validates a filter configuration.

Types

type Engine

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

Engine handles filter evaluation.

func New

func New(filters []Filter, mode Mode) *Engine

New creates a new filter engine.

func (*Engine) Matches

func (e *Engine) Matches(data map[string]any) bool

Matches evaluates all filters against the given data.

type Filter

type Filter struct {
	Value    any    `json:"value"`
	Field    string `json:"field"`
	Operator string `json:"operator"`
}

Filter represents a single filter condition.

type Mode

type Mode string

Mode represents how multiple filters should be combined.

const (
	// ModeAnd combines filters with AND logic (all must match).
	ModeAnd Mode = "and"
	// ModeOr combines filters with OR logic (any can match).
	ModeOr Mode = "or"
)

Jump to

Keyboard shortcuts

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