validation

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(rules []Rule)

func Validate

func Validate(s any) error

Types

type Error

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

func (*Error) Error

func (ve *Error) Error() string

func (*Error) FieldErrors

func (ve *Error) FieldErrors() []FieldError

func (*Error) Unwrap

func (ve *Error) Unwrap() error

type FieldError

type FieldError struct {
	FailedField string      `json:"failedField"`
	Tag         string      `json:"tag"`
	Value       interface{} `json:"value"`
	Message     string      `json:"message"`
}

func (FieldError) Error

func (fe FieldError) Error() string

type Rule

type Rule interface {
	Name() string
	Apply(fl validator.FieldLevel) bool
	Message(field string, value any) string
}

func NewRule

func NewRule(name string, apply func(validator.FieldLevel) bool, msgTempl string) Rule

Jump to

Keyboard shortcuts

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