Branch | Status | Coverage |
---|---|---|
master |
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.
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.FilterMap(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 := NewInputFilter(map[string][]Filter{
"email": {
NewStringToLowerFilter(),
},
})
values := url.Values{}
values.Set("email", "STEVE@APPLE.COM")
value, err := i.FilterValues(values)
// return
// url.Values{
// "email": []string{"steve@apple.com"},
// }
}
Hyperscale Filter is licensed under the MIT license.