The Hyperscale InputFilter library provides a simple inputfilter chaining mechanism by which multiple filters and validator may be applied to a single datum in a user-defined order.

Hyperscale InputFilter Last release Documentation

Go Report Card

Branch Status Coverage
master Build Status Coveralls

The Hyperscale InputFilter library provides a simple inputfilter chaining mechanism by which multiple filters and validator 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"
    "github.com/hyperscale-stack/validator"
    "github.com/hyperscale-stack/inputfilter"
)

func main() {
    i := New(map[string]InputDefinition{
		"*": {
			Filters: []filter.Filter{
				filter.NewStringToLowerFilter(),
			},
		},
		"url": {
			Filters: []filter.Filter{
				filter.NewURLFilter(),
			},
		},
		"id": {
			Validators: []validator.Validator{
				validator.NewUUIDValidator(),
			},
		},
	})

	data, errs := i.FilterMap(map[string]interface{}{
        "id":  "9D2C8507-5F9D-4CB0-A098-2E307B39DC91",
        "url": "HTTPS://google.COM",
    })
    // return 
    // map[string]interface{}{
	//     "id":  "9d2c8507-5f9d-4cb0-a098-2e307b39dc91",
    //     "url": "https://google.com",
    // }
}

Filter by url.Values

package main

import (
    "fmt"

    "github.com/hyperscale-stack/filter"
    "github.com/hyperscale-stack/validator"
    "github.com/hyperscale-stack/inputfilter"
)

func main() {
    i := New(map[string]InputDefinition{
		"*": {
			Filters: []filter.Filter{
				filter.NewStringToLowerFilter(),
			},
		},
		"url": {
			Filters: []filter.Filter{
				filter.NewURLFilter(),
			},
		},
		"id": {
			Validators: []validator.Validator{
				validator.NewUUIDValidator(),
			},
		},
	})

    values := url.Values{}
    values.Set("id", "9D2C8507-5F9D-4CB0-A098-2E307B39DC91")
    values.Set("url", "HTTPS://google.COM")

	data, errs := i.FilterValues(values)
    // return 
    // url.Values{
	//     "id":  []string{"9d2c8507-5f9d-4cb0-a098-2e307b39dc91"},
    //     "url": []string{"https://google.com"},
    // }
}

License

Hyperscale Filter is licensed under the MIT license.

Owner
Hyperscale Stack
Open source golang libraries for build web service
Hyperscale Stack
Similar Resources

Iran National Id, Bank Card Number, Mobile Number Validator for golang

Iran IDValidator Iran National Id, Bank Card Number, Mobile Number Validator for golang Installation go get -u github.com/mohammadv184/idvalidator Us

Dec 20, 2021

Gin Middleware to extract json tag value from playground validator's errors validation

Json Tag Extractor for Go-Playground Validator This is Gin Middleware that aim to extract json tag and than store it to FieldError.Field() object. Ins

Jan 14, 2022

Validator - Replace the validation framework used by gin

validator Replace the validation framework used by gin replace mod:replace githu

Jan 18, 2022

A lightweight model validator written in Go.

validator A lightweight model validator written in Go. quickstart package main import ( "fmt" v "github.com/go-the-way/validator" ) func main() {

Sep 27, 2022

This package provides a framework for writing validations for Go applications.

github.com/gobuffalo/validate This package provides a framework for writing validations for Go applications. It does provide you with few validators,

Dec 15, 2022

Library providing opanapi3 and Go types for store/validation and transfer of ISO-4217, ISO-3166, and other types.

go-types This library has been created with the purpose to facilitate the store, validation, and transfer of Go ISO-3166/ISO-4217/timezones/emails/URL

Nov 9, 2022

This project is a Library to validate a pull secret

This project is a Library to validate a pull secret

lib-ps-validator Description This repository and its contents are completely UNSUPPORTED in any way and are not part of official documentation. Lib to

Jul 21, 2021

Opinionated go to validation library

🙅 valeed Your opinionated go-to validation library. Struct tag-based. Validate here, validate there, validate everywhere. Sleek and simple validation

Jul 21, 2022

A library to remove special characters from a string.

spechar Is a small library for removing special characters from strings. Install First you have to install the package: go get github.com/gowizzard/sp

Dec 13, 2021
Golang parameter validation, which can replace go-playground/validator, includes ncluding Cross Field, Map, Slice and Array diving, provides readable,flexible, configurable validation.
Golang parameter validation, which can replace go-playground/validator, includes ncluding Cross Field, Map, Slice and Array diving, provides readable,flexible, configurable validation.

Checker 中文版本 Checker is a parameter validation package, can be use in struct/non-struct validation, including cross field validation in struct, elemen

Dec 16, 2022
A norms and conventions validator for Terraform

This tool will help you ensure that a terraform folder answer to your norms and conventions rules. This can be really useful in several cases : You're

Nov 29, 2022
:balloon: A lightweight struct validator for Go

gody Go versions supported Installation go get github.com/guiferpa/gody/v2 Usage package main import ( "encoding/json" "fmt" "net/http"

Nov 19, 2022
jio is a json schema validator similar to joi
jio is a json schema validator similar to joi

jio Make validation simple and efficient ! 中文文档 Why use jio? Parameter validation in Golang is really a cursing problem. Defining tags on structs is n

Dec 25, 2022
golang request validator

validator Golang 参数验证器,目前只支持POST请求,JSON格式参数验证 亮点 1、验证时只要有一个错误,错误信息立即返回 2、可自定义参数别名显示错误信息;详情见_example文件 使用 go mod -u github.com/one-gold-coin/validator

Sep 30, 2021
golang rule-based string validator

gosv golang rule-based string validator usage import "github.com/s0rg/gosv" var MyRules = []gosv.Rule{ gosv.MinLen(8), gosv.MaxLen(64), gosv.MinLo

Nov 20, 2021
Checker/validator for Hong Kong IDs

hkidchecker Checker/validator for Hong Kong IDs Description This Go package validates Hong Kong ID card IDs. Useful for example for validating form in

Oct 13, 2021
OpenShift OLM Catalog Validator

OpenShift OLM Catalog Validator Overview It is an external validator which can be used with Operator-SDK to check the vendor-like criteria to publish

Nov 22, 2021
Vat ID Validator for Germany

German Vat Validator service This project has been developed using Hexagonal architecture and repository pattern. How to run? docker-compose up -d Cal

Nov 4, 2021
A demo project shows how to use validator to validate parameters

validator-demo This project is a demo project shows how to use validator to validate parameters use case install requirements go get github.com/favadi

Jan 10, 2022