val

package
v1.42.19 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 Imported by: 1 module, 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

This section is empty.

Functions

func ValidatePassword

func ValidatePassword(password string, errs []string) []string

Types

type Error

type Error struct {
	Fields  []error
	Message string
	Type    string
}

Top level validation error

func NewError

func NewError(message string) *Error

func (Error) Error

func (e Error) Error() string

func (Error) Messages

func (e Error) Messages() map[string]string

Return a map of field error messages

type FieldError

type FieldError struct {
	Field   string
	Message string
}

Error at individual field level

func NewFieldError

func NewFieldError(field string, message string) *FieldError

func (FieldError) Error

func (f FieldError) Error() string

type StringValidationContext

type StringValidationContext struct {
	IsValid bool
	// contains filtered or unexported fields
}

func Check

func Check(str string) *StringValidationContext

func (*StringValidationContext) IsPassword

func (*StringValidationContext) LengthIsGreaterThanOrEqualTo

func (s *StringValidationContext) LengthIsGreaterThanOrEqualTo(n int) *StringValidationContext

Basic Validation

type Validator

type Validator struct {
	Value reflect.Value
	// contains filtered or unexported fields
}

func New

func New() *Validator

Create a new Validator using a custom struct

func (*Validator) Add

func (*Validator) Check

func (v *Validator) Check(field string) *Validator

Set the current field to be Validated

func (*Validator) Ensure

func (v *Validator) Ensure(fn ValidatorFunction) *Validator

func (*Validator) Exec

func (v *Validator) Exec(value interface{}) []error

Generate Validation Errors

func (*Validator) Exists

func (v *Validator) Exists() *Validator

Built in validation routines

func (*Validator) IsEmail

func (v *Validator) IsEmail() *Validator

func (*Validator) IsPassword

func (v *Validator) IsPassword() *Validator

Higher Order Functions

func (*Validator) Matches

func (v *Validator) Matches(strs ...string) *Validator

Use for enums

func (*Validator) MinLength

func (v *Validator) MinLength(minLength int) *Validator

type ValidatorFunction

type ValidatorFunction interface{}

Jump to

Keyboard shortcuts

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