rule

package
v0.0.0-...-84e4e40 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ParamInUnsupported = "unsupported"
	ParamInSupported   = "supported"
)
View Source
var (
	ParamNumMin = "min"
	ParamNumMax = "max"
)
View Source
var (
	ParamSliceMinLen = "minLen"
	ParamSliceMaxLen = "maxLen"
)
View Source
var (
	// ParamMaxLen is the name of string min length parameter.
	ParamStrMaxLen = "maxLen"
	// ParamMaxLen is the name of string max length parameter.
	ParamStrMinLen = "minLen"
)
View Source
var (
	// StrEmail creates validator to check whether a string is an email.
	StrEmail = fromfn(govalidator.IsEmail)
	// StrIPv4 creates validator to check whether a string is an IPv4.
	StrIPv4 = fromfn(govalidator.IsIPv4)
	// StrIPv6 creates validator to check whether a string is an IPv6.
	StrIPv6 = fromfn(govalidator.IsIPv6)
	// StrIP creates validator to check whether a string is an IP.
	StrIP = fromfn(govalidator.IsIP)
	// StrIsURL creates validator to check whether a string is an URL.
	StrIsURL = fromfn(govalidator.IsURL)
	// StrIsUpperCase creates validator to check whether a string is in upper case.
	StrIsUpperCase = fromfn(govalidator.IsUpperCase)
	// StrIsLowerCase creates validator to check whether a string is in lower case.
	StrIsLowerCase = fromfn(govalidator.IsLowerCase)
	// StrIsJSON creates validator to check whether a string is a JSON.
	StrIsJSON = fromfn(govalidator.IsJSON)
)

Functions

func Between

func Between(a, b interface{}, msg string) validation.Rule

Between creates validator to check whether a number is the range provided.

func In

func In(values []interface{}, msg string) validation.Rule

In creates a validator to chech wheter an item belongs to the set provided.

func Max

func Max(max interface{}, msg string) validation.Rule

Max creates validator to check whether a number is not great than the value provided.

func Min

func Min(min interface{}, msg string) validation.Rule

Min creates validator to check whether a number is not less than the value provided.

func NotNil

func NotNil(msg string) validation.Rule

NotNil creates validator to check whether a value is nil.

func SliceEach

func SliceEach(iter SliceIter, rules []validation.Rule) validation.Rule

SliceEach creates validator to check whether all items of a slice meet the rules provided.

func SliceLen

func SliceLen(min, max int, msg string) validation.Rule

SliceLen creates validator to check whether slice length is in the range provided.

func SliceMaxLen

func SliceMaxLen(max int, msg string) validation.Rule

SliceMaxLen creates validator to check whether slice length is not less than the value provided.

func SliceMinLen

func SliceMinLen(min int, msg string) validation.Rule

SliceMinLen creates validator to check whether slice length is not less than the value provided.

func SliceUnique

func SliceUnique(iter SliceIter, msg string) validation.Rule

SliceUnique create validator to check wheter a slice contains only unique items.

func StrLen

func StrLen(min, max int, msg string) validation.Rule

StrLen creates validator to check whether length of a string is in the range provided. The 'msg' parameter should be a format string with 2 slots for int.

func StrMatch

func StrMatch(pattern *regexp.Regexp, msg string) validation.Rule

StrMatch creates validator to check whether a string matches the regular expression provided.

func StrMaxLen

func StrMaxLen(max int, msg string) validation.Rule

StrMaxLen creates validator to check whether length of a string is not great than the value provided. The 'msg' parameter should be a format string with 1 slot for int.

func StrMinLen

func StrMinLen(min int, msg string) validation.Rule

StrMinLen creates validator to check whether length of a string is not less than the value provided. The 'msg' parameter should be a format string with 1 slot for int.

func StrRequired

func StrRequired(msg string) validation.Rule

StrRequired creates validator to check whether a string is blank.

Types

type SliceIter

type SliceIter func(interface{}, int) interface{}

SliceIter represent iterator interface for slice.

Jump to

Keyboard shortcuts

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