validator

package
v0.0.0-...-91b10cc Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func In

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

In checks if a string value is present in a list of strings.

func Matches

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

Matches checks if a string value matches a specific regexp pattern.

Types

type Errors

type Errors = map[string]string

Errors is a types alias of map[string]string

type Validator

type Validator struct {
	Errors Errors
}

func New

func New() *Validator

New creates and returns an instance of a Validator.

func (*Validator) AddError

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

AddError adds a new error to Validator.Errors with a given key and message. If key already exists in the map, the message won't be added

func (*Validator) Check

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

Check checks a boolean expression. If the expression evaluates to `false`, an error will be added to Validator.Errors

func (*Validator) Valid

func (v *Validator) Valid() bool

Valid returns true if the Validator.Errors map doesn't contain any entries.

Jump to

Keyboard shortcuts

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