validator

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidationErrorMessages = map[string]string{
	"default":     "The :field field is invalid.",
	"required":    "The :field field is required.",
	"len":         "The :field must be :value.",
	"min":         "The :field must be at least :value.",
	"max":         "The :field may not be greater than :value.",
	"eq":          "The :field must be :value.",
	"ne":          "The :field must not be :value.",
	"gte":         "The :field must have more than or equal to :value.",
	"gt":          "The :field must have more than :value.",
	"lte":         "The :field may not be greater than or equal to :value.",
	"lt":          "The :field may not be greater than :value.",
	"eqfield":     "The :field and :value must match.",
	"nefield":     "The :field field is invalid.",
	"alpha":       "The :field may only contain letters.",
	"alphanum":    "The :field may only contain letters and numbers.",
	"numeric":     "The :field must be a number.",
	"hexadecimal": "The :field must be a hexadecimal.",
	"hexcolor":    "The :field must be a hexcolor.",
	"rgb":         "The :field does not match the format rgb.",
	"rgba":        "The :field does not match the format rgba.",
	"hsl":         "The :field does not match the format hsl.",
	"hsla":        "The :field does not match the format hsla.",
	"email":       "The :field must be a valid email address.",
	"url":         "The :field format is invalid.",
	"uri":         "The :field format is invalid.",
	"contains":    "The selected :field is invalid.",
	"containsany": "The selected :field is invalid.",
	"excludes":    "The selected :field is invalid.",
	"excludesall": "The selected :field is invalid.",
	"isbn":        "The :field must be a valid ISBN number.",
	"uuid":        "The :field must be a valid UUID.",
	"uuid3":       "The :field must be a valid UUID3.",
	"uuid4":       "The :field must be a valid UUID4.",
	"uuid5":       "The :field must be a valid UUID5.",
	"ascii":       "The :field must be a valid IP address.",
	"latitude":    "The :field must be a valid latitude.",
	"longitude":   "The :field must be a valid longitude.",
	"ip":          "The :field must be a valid IP address.",
	"ipv4":        "The :field must be a valid IPv4 address.",
	"ipv6":        "The :field must be a valid IPv6 address.",
	"mac":         "The :field must be a valid MAC address.",
	"countrycode": "The :field is invalid.",
	"requiredif":  "The :field field is required.",
	"phonenumber": "The :field must be a valid phone number.",
}

ValidationErrorMessages : validation error message

Functions

func Validate

func Validate(tag string, i interface{}) error

Validate : validate fields

Types

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

ValidationError :

func (ValidationError) Error

func (ve ValidationError) Error() string

Error :

func (ValidationError) MarshalJSON

func (ve ValidationError) MarshalJSON() ([]byte, error)

MarshalJSON :

Jump to

Keyboard shortcuts

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