validation

package
v3.64.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Required = RequiredRule{}
	Slug     = SlugRule{}
	UUID     = UUIDRule{}
	MinValue = func(min int) MinValueRule {
		return MinValueRule{min: min}
	}
)

Common rules that can be reused

Functions

This section is empty.

Types

type MinValueRule

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

func (MinValueRule) Validate

func (r MinValueRule) Validate(value interface{}) error

type RequiredRule

type RequiredRule struct{}

func (RequiredRule) Validate

func (r RequiredRule) Validate(value interface{}) error

type Rule

type Rule interface {
	Validate(value interface{}) error
}

type SlugRule

type SlugRule struct{}

func (SlugRule) Validate

func (r SlugRule) Validate(value interface{}) error

type UUIDRule

type UUIDRule struct{}

func (UUIDRule) Validate

func (r UUIDRule) Validate(value interface{}) error

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func (ValidationErrors) Error

func (e ValidationErrors) Error() string

type Validator

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

func New

func New() *Validator

func (*Validator) AddRule

func (v *Validator) AddRule(field string, rule Rule)

func (*Validator) Validate

func (v *Validator) Validate(fields map[string]interface{}) error

Validate validates a map of field/value pairs

Jump to

Keyboard shortcuts

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