validate

package
v0.31.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package validate supplies a struct validator to validate whether the field value of the struct is valid or not.

Index

Constants

This section is empty.

Variables

View Source
var Validate = validator.New()

Validate is the default global validator.

View Source
var ValidateErrorFormatters = make(map[string]func(validator.FieldError) error)

ValidateErrorFormatters is the set of formatters to format validator.FieldError.

Functions

func RegisterValidateErrorFormatter

func RegisterValidateErrorFormatter(name string, f func(validator.FieldError) error)

RegisterValidateErrorFormatter registers the field error formatter with the name, which will override it if the name has been registered.

If name is empty, it will panic. If f is nil, it will delete it.

func SetValidateTagName

func SetValidateTagName(validator *validator.Validate, tags ...string)

SetValidateTagName registers a tag name function with the given tags into v.

func StructValidator

func StructValidator(validate *validator.Validate) func(interface{}) error

StructValidator returns a new struct validator function, which is used to set the validator of the github.com/xgfone/ship#Ship.Validator.

If validate is nil, it is the global Validate by default.

Types

This section is empty.

Jump to

Keyboard shortcuts

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