valid

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooLow        = errors.NewFrozenError("TOO_LOW", "Value is too low", 400)
	ErrTooHigh       = errors.NewFrozenError("TOO_HIGH", "Value is too high", 400)
	ErrTooShort      = errors.NewFrozenError("TOO_SHORT", "Value is too short", 400)
	ErrTooLong       = errors.NewFrozenError("TOO_LONG", "Value is too long", 400)
	ErrRequired      = errors.NewFrozenError("REQUIRED", "Value is required", 400)
	ErrFailedEnum    = errors.NewFrozenError("FAILED_ENUM", "Invalid value", 400)
	ErrFailedPattern = errors.NewFrozenError("FAILED_PATTERN", "Value does not match pattern", 400)
	ErrFailedDefault = errors.NewFrozenError("FAILED_DEFAULT", "Default value can't be set", 500)
)

Functions

func ValidateStruct added in v0.25.0

func ValidateStruct[T any](ptr *T, errs *errors.Errors) bool

Types

type StructValidator

type StructValidator[T any] func(ptr *T, errs *errors.Errors) bool

Validates T and returns a boolean whether it's valid

func CreateStructValidator

func CreateStructValidator[T any]() (StructValidator[T], error)

Create a validator that can be reused for a specific struct type.

func GetStructValidator added in v0.25.0

func GetStructValidator[T any]() (StructValidator[T], error)

Jump to

Keyboard shortcuts

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