validators

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorMessage_Default = "field value is invalid"

	ErrorMessage_Required        = "value is required"
	ErrorMessage_UUID            = "value must be a valid UUID"
	ErrorMessage_Equals          = "value must be equal to '%s'"
	ErrorMessage_HTTP_URL        = "value must a valid http url"
	ErrorMessage_GreaterThan     = "value must be greater than '%s'"
	ErrorMessage_RequiredWithout = "value or '%s' is required"
	ErrorMessage_RequiredWith    = "value is required when '%s' is set"
)

Functions

func RegisterCustomValidation

func RegisterCustomValidation(name string, vldFunc ValidationFunc, opts ...ValidationOpt)

func ValidateStruct

func ValidateStruct(s interface{}) error

Types

type ValidationError

type ValidationError struct {
	Field string      `json:"field"`
	Param string      `json:"param,omitempty"`
	Value interface{} `json:"value"`
	Err   string      `json:"error"`
}

type ValidationErrors

type ValidationErrors []ValidationError

func (ValidationErrors) Error

func (ve ValidationErrors) Error() string

type ValidationFunc added in v0.5.0

type ValidationFunc validator.Func

type ValidationOpt added in v0.5.0

type ValidationOpt func(string)

func WithValidationErrorMessage added in v0.5.0

func WithValidationErrorMessage(msg string) ValidationOpt

Jump to

Keyboard shortcuts

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