validator

package
v0.0.0-...-5b94ac3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const MissingFieldErrMsg string = "must be provided"

MissingFieldErrMsg is a string representation of a missing field value.

Variables

This section is empty.

Functions

func In

func In(value string, list ...string) bool

In returns true if a specific value is in a list of strings.

func IsUnique

func IsUnique(list ...string) bool

IsUnique returns true if all string values in a slice are unique.

func Matches

func Matches(value string, rx regexp.Regexp) bool

Matches returns true if a string value matches a specific regexp pattern.

Types

type Validator

type Validator struct {
	Errors map[string]string
}

Validator encapsulates a set of validation rules and methods.

func New

func New() *Validator

New returns a configured instance of *Validator

func (*Validator) AddError

func (v *Validator) AddError(errKey, errMsg string)

AddError adds new errors to the errors map.

func (*Validator) Check

func (v *Validator) Check(condition bool, errKey, errMsg string)

Check performs a boolean check on the value and appends the errMsg to the errors map.

func (*Validator) IsValid

func (v *Validator) IsValid() bool

IsValid checks if a particular value is valid according to the applied rules.

Jump to

Keyboard shortcuts

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