Documentation
¶
Index ¶
- Constants
- Variables
- func FromAPIFilterBoolean(f *FilterBoolean) (*filter.FilterBoolean, error)
- func FromAPIFilterDateTime(f *FilterDateTime) (*filter.FilterTime, error)
- func FromAPIFilterLabel(f *FilterLabel) (*filter.FilterString, error)
- func FromAPIFilterLabels(f *FilterLabels) (map[string]filter.FilterString, error)
- func FromAPIFilterNumeric(f *FilterNumeric) (*filter.FilterFloat, error)
- func FromAPIFilterString(f *FilterString) (*filter.FilterString, error)
- func FromAPIFilterStringExact(f *FilterStringExact) (*filter.FilterString, error)
- func FromAPIFilterULID(f *FilterULID) (*filter.FilterULID, error)
- func FromAPIStatusFilter[T validator[T]](ctx context.Context, f *FilterStringExact) ([]T, error)
- func Parse(qs url.Values, target any) error
- type FilterBoolean
- type FilterDateTime
- type FilterLabel
- type FilterLabels
- type FilterNumeric
- type FilterString
- type FilterStringExact
- type FilterULID
Constants ¶
const ( OpEq = "eq" OpNeq = "neq" OpGt = "gt" OpGte = "gte" OpLt = "lt" OpLte = "lte" OpContains = "contains" OpOeq = "oeq" OpOcontains = "ocontains" OpExists = "exists" OpNexists = "nexists" )
Operator constants used in filter[field][op]=value query parameters.
Variables ¶
var ( ErrTooManyItems = fmt.Errorf("too many comma-separated items (max %d)", maxCommaSeparatedItems) ErrUnsupportedOperator = errors.New("unsupported operator") ErrInvalidNumber = errors.New("invalid number") ErrInvalidDateTime = errors.New("invalid datetime") )
var (
FilterULIDType = reflect.TypeFor[*FilterULID]()
)
Functions ¶
func FromAPIFilterBoolean ¶
func FromAPIFilterBoolean(f *FilterBoolean) (*filter.FilterBoolean, error)
FromAPIFilterBoolean converts an API FilterBoolean to filter.FilterBoolean.
func FromAPIFilterDateTime ¶
func FromAPIFilterDateTime(f *FilterDateTime) (*filter.FilterTime, error)
FromAPIFilterDateTime converts an API FilterDateTime to filter.FilterTime.
func FromAPIFilterLabel ¶
func FromAPIFilterLabel(f *FilterLabel) (*filter.FilterString, error)
FromAPIFilterLabel converts an API FilterLabel to filter.FilterString.
func FromAPIFilterLabels ¶
func FromAPIFilterLabels(f *FilterLabels) (map[string]filter.FilterString, error)
FromAPIFilterLabels converts an API FilterLabels to map[string]filter.FilterString.
func FromAPIFilterNumeric ¶
func FromAPIFilterNumeric(f *FilterNumeric) (*filter.FilterFloat, error)
FromAPIFilterNumeric converts an API FilterNumeric to filter.FilterFloat.
func FromAPIFilterString ¶
func FromAPIFilterString(f *FilterString) (*filter.FilterString, error)
FromAPIFilterString converts an API FilterString to filter.FilterString.
func FromAPIFilterStringExact ¶
func FromAPIFilterStringExact(f *FilterStringExact) (*filter.FilterString, error)
FromAPIFilterStringExact converts an API FilterStringExact to filter.FilterString.
func FromAPIFilterULID ¶
func FromAPIFilterULID(f *FilterULID) (*filter.FilterULID, error)
FromAPIFilterULID converts an API FilterString to filter.FilterULID.
func FromAPIStatusFilter ¶
func FromAPIStatusFilter[T validator[T]](ctx context.Context, f *FilterStringExact) ([]T, error)
Types ¶
type FilterBoolean ¶
type FilterBoolean struct {
// Eq requires the field to match the provided value exactly.
Eq *bool `json:"eq,omitempty"`
}
FilterBoolean represents a filter operation on a boolean field.
type FilterDateTime ¶
type FilterDateTime struct {
// Eq requires the field to match the provided value exactly.
Eq *time.Time `json:"eq,omitempty"`
// Gt requires the field to be greater than the provided value.
Gt *time.Time `json:"gt,omitempty"`
// Gte requires the field to be greater than or equal to the provided value.
Gte *time.Time `json:"gte,omitempty"`
// Lt requires the field to be less than the provided value.
Lt *time.Time `json:"lt,omitempty"`
// Lte requires the field to be less than or equal to the provided value.
Lte *time.Time `json:"lte,omitempty"`
}
FilterDateTime represents a filter operation on a datetime field.
type FilterLabel ¶
type FilterLabel struct {
// Eq requires the field to match the provided value exactly.
Eq *string `json:"eq,omitempty"`
// Contains requires the field to contain the provided value (case-insensitive).
Contains *string `json:"contains,omitempty"`
// Ocontains requires the field to contain any of the provided comma-separated values (case-insensitive).
Ocontains []string `json:"ocontains,omitempty"`
// Oeq requires the field to match any of the provided comma-separated values (case-sensitive).
Oeq []string `json:"oeq,omitempty"`
// Neq requires the field to not match the provided value.
Neq *string `json:"neq,omitempty"`
}
FilterLabel represents a filter operation on a label key.
type FilterLabels ¶
type FilterLabels = map[string]FilterLabel
FilterLabels is a map of label keys to filter operations.
type FilterNumeric ¶
type FilterNumeric struct {
// Eq requires the field to match the provided value exactly.
Eq *float64 `json:"eq,omitempty"`
// Neq requires the field to not match the provided value.
Neq *float64 `json:"neq,omitempty"`
// Oeq requires the field to match any of the provided comma-separated values.
Oeq []float64 `json:"oeq,omitempty"`
// Gt requires the field to be greater than the provided value.
Gt *float64 `json:"gt,omitempty"`
// Gte requires the field to be greater than or equal to the provided value.
Gte *float64 `json:"gte,omitempty"`
// Lt requires the field to be less than the provided value.
Lt *float64 `json:"lt,omitempty"`
// Lte requires the field to be less than or equal to the provided value.
Lte *float64 `json:"lte,omitempty"`
}
FilterNumeric represents a filter operation on a numeric field.
type FilterString ¶
type FilterString struct {
// Eq requires the field to match the provided value exactly (case-sensitive).
Eq *string `json:"eq,omitempty"`
// Neq requires the field to not match the provided value (case-sensitive).
Neq *string `json:"neq,omitempty"`
// Gt requires the field to be greater than the provided value.
Gt *string `json:"gt,omitempty"`
// Gte requires the field to be greater than or equal to the provided value.
Gte *string `json:"gte,omitempty"`
// Lt requires the field to be less than the provided value.
Lt *string `json:"lt,omitempty"`
// Lte requires the field to be less than or equal to the provided value.
Lte *string `json:"lte,omitempty"`
// Contains requires the field to contain the provided value (case-insensitive).
Contains *string `json:"contains,omitempty"`
// Oeq requires the field to match any of the provided comma-separated values (case-sensitive).
Oeq []string `json:"oeq,omitempty"`
// Ocontains requires the field to contain any of the provided comma-separated values (case-insensitive).
Ocontains []string `json:"ocontains,omitempty"`
// Exists requires the field to be present (true) or absent (false).
Exists *bool `json:"$exists,omitempty"`
}
FilterString represents a filter operation on a string field.
type FilterStringExact ¶
type FilterStringExact struct {
// Eq requires the field to match the provided value exactly (case-sensitive).
Eq *string `json:"eq,omitempty"`
// Neq requires the field to not match the provided value exactly (case-sensitive).
Neq *string `json:"neq,omitempty"`
// Oeq requires the field to match any of the provided comma-separated values (case-sensitive).
Oeq []string `json:"oeq,omitempty"`
}
FilterStringExact represents a filter operation on a string field that only supports exact matching.
type FilterULID ¶
type FilterULID struct {
// Eq requires the field to match the provided value exactly (case-sensitive).
Eq *string `json:"eq,omitempty"`
// Neq requires the field to not match the provided value (case-sensitive).
Neq *string `json:"neq,omitempty"`
// Oeq requires the field to match any of the provided comma-separated values (case-sensitive).
Oeq []string `json:"oeq,omitempty"`
}
FilterULID represents a filter operation on a string field that satisfies ULID format.