validate

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 52

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormatErrorFunc

type FormatErrorFunc func(target interface{}, err validator.FieldError) string

type Validator

type Validator struct {
	FormatErrorFuncMap map[string]FormatErrorFunc
	// contains filtered or unexported fields
}

func New

func New() *Validator

func (*Validator) RegisterCollectionValidator

func (v *Validator) RegisterCollectionValidator(singularName, pluralName string, allowedValues []string)

RegisterCollectionValidator 要素/コレクションを示す単数名/複数名に対しそれぞれoneof/diveエイリアスを登録する

("zone", "zones", []string{"v1", "v2"}) とした場合、以下のエイリアスがバリデーターに登録される

  • "zone" => "oneof=v1 v2"のエイリアス
  • "zones" => "dive,zone"のエイリアス

func (*Validator) Struct

func (v *Validator) Struct(value interface{}) error

Struct 対象structを検証しerrorを返す

func (*Validator) StructWithMultiError

func (v *Validator) StructWithMultiError(value interface{}) *multierror.Error

StructWithMultiError 対象structを検証し、*multierror.Errorを返す

Jump to

Keyboard shortcuts

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