validator

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWebProxyAlias added in v0.62.2

func IsWebProxyAlias(s string) bool

IsWebProxyAlias reports whether s is a valid web-proxy alias: a strict lowercase RFC 1123 DNS label (1-63 characters of a-z, 0-9 and '-', starting and ending with a letter or digit) that additionally contains no "--" (the web proxy's host-label separator) and is not all digits (an all-digit first segment, as in "8080--tul-fm", is read as the port form, so such an alias could never be reached). Unlike plainhostname it rejects uppercase. It is exported so services can validate an alias that only exists after CEL evaluation, where the struct tag never ran.

func RegisterCustomValidators

func RegisterCustomValidators(v *validator.Validate)

Register custom validators

Types

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Value   string `json:"value,omitempty"`
}

ValidationError represents a user-friendly validation error

type Validator

type Validator []ValidationError

ValidationErrors is a collection of validation errors

func NewValidator

func NewValidator(s interface{}) Validator

func (Validator) ErrorMessages

func (ve Validator) ErrorMessages() string

func (Validator) Errors

func (ve Validator) Errors() []ValidationError

func (Validator) IsValid

func (ve Validator) IsValid() bool

Jump to

Keyboard shortcuts

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