params

package
v0.0.0-...-ed79881 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCIDR

func IsCIDR(i interface{}, others map[string]interface{}) error

func IsFilepath

func IsFilepath(i interface{}, others map[string]interface{}) error

IsFilepath checks if value is a file path.

func IsIP

func IsIP(i interface{}, others map[string]interface{}) (err error)

func IsInEnumIgnoreCase

func IsInEnumIgnoreCase(items ...string) validatorFunc

IsInEnumIgnoreCase checks if value is in `items` (case insensitive).

func List

func List(r Rule) (required []string, optionals []string, suggested []string)

func MaxLengthOf

func MaxLengthOf(l int) validatorFunc

MaxLengthOf checks if value length is less than `l`.

func MinLengthOf

func MinLengthOf(l int) validatorFunc

MinLengthOf checks if value length is at least `l`.

func Run

func Run(r Rule, input []string) error

func SpecBuilder

func SpecBuilder(r Rule, vs ...Validators) *specBuilder

func Suggested

func Suggested(s ...string) (sugs []suggested)

func Validate

func Validate(all Validators, paramValues map[string]interface{}) error

Validate checks if `paramValues` match `all` Validators.

Types

type Reducer

type Reducer interface {
	Keys() []string
	Reduce(map[string]interface{}) (map[string]interface{}, error)
}

Reducer is a program which apply `reduceFunc` to values.

type Rule

type Rule interface {
	Visit(func(Rule))
	Run(input []string) error
	Required() []string
	Missing(input []string) []string
	String() string
}

func AllOf

func AllOf(rules ...Rule) Rule

func AtLeastOneOf

func AtLeastOneOf(rules ...Rule) Rule

func Key

func Key(k string) Rule

func None

func None() Rule

func OnlyOneOf

func OnlyOneOf(rules ...Rule) Rule

func Opt

func Opt(i ...interface{}) Rule

type Spec

type Spec interface {
	Rule() Rule
	Reducers() []Reducer
	Validators() Validators
}

Spec specifies a set of transformations to parameters including Rules, Reducers and Validators.

func NewSpec

func NewSpec(r Rule, vs ...Validators) Spec

NewSpec creates a new Spec.

type Validators

type Validators map[string]validatorFunc

Validators are a map of validator functions.

Jump to

Keyboard shortcuts

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