validator

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Required = iota
	Int
	Float
	String
	JSON
	IP
	Match
)

Variables

This section is empty.

Functions

func ValidateHttp

func ValidateHttp(c *gin.Context, action string, labels Label, rules []Rule) (bool, error)

Types

type FloatValidator

type FloatValidator struct {
	Min float64
	Max float64
}

func (FloatValidator) Check

func (v FloatValidator) Check(value interface{}) (bool, error)

type IPValidator

type IPValidator struct {
}

func (IPValidator) Check

func (v IPValidator) Check(value interface{}) (bool, error)

type IntValidator

type IntValidator struct {
	Min int
	Max int
}

func (IntValidator) Check

func (v IntValidator) Check(value interface{}) (bool, error)

type JSONValidator

type JSONValidator struct {
}

func (JSONValidator) Check

func (v JSONValidator) Check(value interface{}) (bool, error)

type Label

type Label map[string]string

func (*Label) Get

func (l *Label) Get(key string) string

type MatchValidator

type MatchValidator struct {
	Pattern string
}

func (MatchValidator) Check

func (v MatchValidator) Check(value interface{}) (bool, error)

type RequiredValidator

type RequiredValidator struct {
}

func (RequiredValidator) Check

func (v RequiredValidator) Check(value interface{}) (bool, error)

type Rule

type Rule struct {
	Params  []string
	Method  int
	On      []string
	Min     float64
	Max     float64
	Pattern string
	Message string
}

type StringValidator

type StringValidator struct {
	Min int
	Max int
}

func (StringValidator) Check

func (v StringValidator) Check(value interface{}) (bool, error)

type Validator

type Validator interface {
	Check(v interface{}) (bool, error)
}

Jump to

Keyboard shortcuts

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