validator

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package validator provides convenient utilities for validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(v interface{}) error

Validate a struct exposed fields base on the definition of validate tag.

func ValidateExcept added in v0.2.0

func ValidateExcept(v interface{}, fields ...string) error

ValidateExcept validates all the fields except the given fields.

func ValidatePartial added in v0.2.0

func ValidatePartial(v interface{}, fields ...string) error

ValidatePartial validates the fields passed in only, ignoring all others.

func Var

func Var(field interface{}, tag string) error

Var validates a single variable using tag style validation.

Types

type Validator added in v0.1.9

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

Validator is a validation helper.

func Get added in v0.2.0

func Get(tag string) *Validator

Get get the tag validator from cache or create new one if not exists. If tag is empty, return Root() validator.

func Init added in v0.1.9

func Init(tag string) *Validator

Init inits the root validator with the given tag.

func New

func New(tag string) *Validator

New return new instance of validator with the given tag.

func Root added in v0.1.9

func Root() *Validator

Root return root validator instance using default 'validate' tag.

func (*Validator) Register added in v0.1.9

func (validator *Validator) Register(tag string, fn validate.Func, callValidationEvenIfNull bool) error

Register adds a validation with the given tag

func (*Validator) Validate added in v0.1.9

func (validator *Validator) Validate(v interface{}) error

Validate a struct exposed fields base on the definition of validate tag.

func (*Validator) ValidateExcept added in v0.1.9

func (validator *Validator) ValidateExcept(v interface{}, fields ...string) error

ValidateExcept validates all the fields except the given fields.

func (*Validator) ValidatePartial added in v0.1.9

func (validator *Validator) ValidatePartial(v interface{}, fields ...string) error

ValidatePartial validates the fields passed in only, ignoring all others.

func (*Validator) Var added in v0.1.9

func (validator *Validator) Var(field interface{}, tag string) error

Var validates a single variable using tag style validation.

Jump to

Keyboard shortcuts

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