validation

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validator

type Validator interface {
	// Register custom modifier.
	RegisterModifier(name string, fn func(in string) (out string)) error
	// Modify struct field value according to modifier tag.
	// Param `data` should be a pointer.
	Modify(data interface{}) error

	// Register custom validator.
	RegisterValidator(name string, fn func(value interface{}, param ...string) (ok bool)) error
	// Register error message handler.
	RegisterValidatorError(name string, fn func(field string, param ...string) (msg error)) error
	// Validate struct field value according to validator tag.
	// Param `data` should be a pointer.
	Validate(data interface{}) error
}

Validator is validating interface.

See usage example in example folder.

func New

func New(mod bool) Validator

New to create new validator. Pass true if you want to modify the data automatically before validate.

Directories

Path Synopsis
Package playground is a wrapper of the original "github.com/go-playground/validator" and "github.com/go-playground/mold" library.
Package playground is a wrapper of the original "github.com/go-playground/validator" and "github.com/go-playground/mold" library.

Jump to

Keyboard shortcuts

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