validator

package
v0.0.0-...-7f40e33 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxLength

func MaxLength(value string, max int) bool

MaxLength returns true if the value is less than or equal to the max length.

func NotBlank

func NotBlank(value string) bool

NotBlank returns true if the value is not empty.

func PermittedValue

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

PermittedValue returns true if the value is in the list of permitted values.

Types

type Validator

type Validator struct {
	FieldErrors map[string]string
}

Validator is a struct that contains a map of field errors.

func (*Validator) AddFieldError

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

AddFieldError adds an error message to the map of field errors.

func (*Validator) CheckField

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

CheckField checks if a condition is met and adds an error message to the map of field errors if it is not.

func (*Validator) Valid

func (v *Validator) Valid() bool

Valid returns true if the Validator has no field errors.

Jump to

Keyboard shortcuts

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