filter

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 6 Imported by: 1

README

Hyperscale Filter Last release Documentation

Go Report Card

Branch Status Coverage
master Build Status Coveralls

The Hyperscale Filter library provides a set of commonly needed data filters. It also provides a simple filter chaining mechanism by which multiple filters may be applied to a single datum in a user-defined order.

Example

Filter by map[string]interface{}

package main

import (
    "fmt"
    "github.com/hyperscale-stack/filter"
)

func main() {

    i := NewInputFilter(map[string][]Filter{
		"email": {
			NewStringToLowerFilter(),
		},
	})

	value, err := i.Filter(map[string]interface{}{
		"email":  "STEVE@APPLE.COM",
    })
    // return 
    // map[string]interface{}{
	//     "email":  "steve@apple.com",
    // }
}

Filter by url.Values

package main

import (
    "fmt"
    "github.com/hyperscale-stack/filter"
)

func main() {

    i := NewValuesFilter(map[string][]Filter{
		"email": {
			NewStringToLowerFilter(),
		},
	})

    values := url.Values{}
    values.Set("email", "STEVE@APPLE.COM")

	value, err := i.Filter(values)
    // return 
    // url.Values{
	//     "email":  []string{"steve@apple.com"},
    // }
}

License

Hyperscale Filter is licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Filter(value Value) (Value, error)
}

Filter interface.

func NewBoolFilter

func NewBoolFilter() Filter

NewBoolFilter constructor.

func NewFloatFilter

func NewFloatFilter() Filter

NewFloatFilter constructor.

func NewIntFilter

func NewIntFilter() Filter

NewIntFilter constructor.

func NewNicknameFilter

func NewNicknameFilter() Filter

NewNicknameFilter constructor.

func NewSlugFilter

func NewSlugFilter(opts ...SlugOption) Filter

NewSlugFilter constructor.

func NewStringToLowerFilter

func NewStringToLowerFilter() Filter

NewStringToLowerFilter constructor.

func NewStringToUpperFilter

func NewStringToUpperFilter() Filter

NewStringToUpperFilter constructor.

func NewStringTrimFilter

func NewStringTrimFilter() Filter

NewStringTrimFilter constructor.

func NewURLFilter

func NewURLFilter(opts ...URLOption) Filter

NewURLFilter constructor.

type InputFilter

type InputFilter interface {
	Filter(input map[string]interface{}) (map[string]interface{}, error)
}

InputFilter interface.

func NewInputFilter

func NewInputFilter(filters map[string][]Filter) InputFilter

NewInputFilter constructor.

type InputValue

type InputValue map[string]interface{}

InputValue type.

type SlugOption

type SlugOption func(*slugFilter)

SlugOption type.

func SlugLanguage

func SlugLanguage(language string) SlugOption

SlugLanguage config language for SlugFilter.

type URLOption

type URLOption func(*urlFilter)

URLOption type.

func URLStripUTMParameters

func URLStripUTMParameters() URLOption

URLStripUTMParameters remove all utm_* query parameters.

type Value

type Value interface{}

Value type.

type ValuesFilter

type ValuesFilter interface {
	Filter(input url.Values) (url.Values, error)
}

ValuesFilter interface.

func NewValuesFilter

func NewValuesFilter(filters map[string][]Filter) ValuesFilter

NewValuesFilter constructor.

Jump to

Keyboard shortcuts

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