validation

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 3 Imported by: 0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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