validator

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(data interface{}) []error

Validate takes an interface as input and get the tags of each fields after processing the tags it will get a appropriate validator and calls the validate func

Types

type RequiredFields

type RequiredFields struct{}

RequiredFields is a type of validator which validates fields with tag required, and it throws and error if the value is empty

func (*RequiredFields) Validate

func (re *RequiredFields) Validate(field string, val interface{}) error

type Type

type Type string

Type custom type for different validator names

const (
	TagName       Type = "validate"
	FieldRequired Type = "required"
)

type Validator

type Validator interface {
	Validate(string, interface{}) error
}

Validator provides an interface for all the different types of validators, all those should implement the method validate

Jump to

Keyboard shortcuts

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