validation

package
v0.0.0-...-b1aaf46 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 9 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("object is invalid")
View Source
var ErrNilObject = errors.New("object is nil")

Functions

func IsValid

func IsValid[T any](obj T) bool

IsValid will check if an object is valid according to the validation tags on the object. It does not return any details of validation issues, only a boolean for valid (true) or invalid (false).

func SanitizeBytes

func SanitizeBytes(data []byte) []byte

SanitizeBytes attempts to "sanitize" a []byte value. It will strip any leading/trailing whitespace and then run the string through bluemonday to remove dangerous components. This should retain HTML5 content.

func SanitizeInput

func SanitizeInput(str string) string

SanitizeInput first runs the string through SanitizeString, then unescapes any HTML encoding of the string.

func SanitizeString

func SanitizeString(str string) string

SanitizeString attempts to "sanitize" a string value. It will strip any leading/trailing whitespace and then run the string through bluemonday to remove dangerous components. This should retain HTML5 content.

func SanitizeURLString

func SanitizeURLString(str string) (string, error)

SanitizeURLString attempts to "sanitize" a string value representing a URL. It first runs the string through SanitizeString, then unescapes the any path, then parses the URL and returns its string representation.

Types

type Error

type Error struct {
	Details string
	// contains filtered or unexported fields
}

Error is a map of fields and their validation errors.

func ParseStructValidationErrors

func ParseStructValidationErrors(validationErrors validator.ValidationErrors) *Error

ParseStructValidationErrors takes the underlying validation errors and formats them so that each struct field has an array of all validation errors associated with it.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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