validator

package
v0.0.0-...-b63fe73 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxChars

func MaxChars(value string, n int) bool

MaxChars checks if a string contains no more than a specified number of characters.

func NotBlank

func NotBlank(value string) bool

NotBlank checks if a string is not blank (i.e., it contains non-whitespace characters).

func PermittedValue

func PermittedValue[T comparable](value T, permittedValues ...T) bool

PermittedValue checks if a value is within a list of permitted values.

Types

type Validator

type Validator struct {
	Errors map[string]string // A map to store validation errors.
}

Validator represents a validation object that holds validation errors.

func (*Validator) AddError

func (v *Validator) AddError(field, message string)

AddError adds an error message for a specific field.

func (*Validator) CheckField

func (v *Validator) CheckField(ok bool, key, message string)

CheckField adds an error message if the validation check fails.

func (*Validator) Valid

func (v *Validator) Valid() bool

Valid checks if there are no validation errors.

Jump to

Keyboard shortcuts

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