verify

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package verify implements certain verification methods for simple data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(fields map[string]error) error

All verifies a map of fields.

func Errorf

func Errorf(s string, args ...interface{}) error

Errorf creates a verify error

func Float

func Float(i float64, verifiers ...FloatVerify) error

Float verifies float64s.

func FloatPositive

func FloatPositive(i float64) error

FloatPositive verifies that an float64 is positive.

func Int

func Int(i int, verifiers ...IntVerify) error

Int verifies ints.

func IntPositive

func IntPositive(i int) error

IntPositive verifies that an int is positive.

func Names

func Names(s string) error

Names specify that the names must be a non-empty string of maximum length 32.

func NotNull

func NotNull(b []byte) error

NotNull verifies that the []byte is not null.

func NullInt

func NullInt(i sql.NullInt64, verifiers ...IntVerify) error

NullInt verifies a NullInt, if it is valid.

func Password

func Password(s string) error

Password specify that the passwords must be a string of length between 9 and 32.

func String

func String(s string, verifiers ...StringVerify) error

String runs verification on a string against a list of verifiers.

func StringNonEmpty

func StringNonEmpty(s string) error

StringNonEmpty verifies that a string is not empty.

Types

type Error

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

Error is error by verify

func (Error) Error

func (e Error) Error() string

Error implements the error interface

type FloatVerify

type FloatVerify func(float64) error

FloatVerify are float64 verifiers.

func FloatMax

func FloatMax(l float64) FloatVerify

FloatMax verifies that the float64 is at most l.

func FloatMin

func FloatMin(l float64) FloatVerify

FloatMin verifies that the float64 is at least l.

func FloatRange

func FloatRange(low, high float64) FloatVerify

FloatRange verifies that an float64 is in range.

type IntVerify

type IntVerify func(int) error

IntVerify are int verifiers.

func IntMax

func IntMax(l int) IntVerify

IntMax verifies that the int is at most l.

func IntMin

func IntMin(l int) IntVerify

IntMin verifies that the int is at least l.

func IntRange

func IntRange(low, high int) IntVerify

IntRange verifies that an int is in range.

type StringVerify

type StringVerify func(string) error

StringVerify are string verifiers.

func Enum

func Enum(values ...string) StringVerify

Enum verifies that a string is in a set of values.

func Regexp

func Regexp(r *regexp.Regexp) StringVerify

Regexp verifies that a string matches a regular expression exactly.

func StringEmptyOr

func StringEmptyOr(f StringVerify) StringVerify

StringEmptyOr passes the check if the string is empty, and complain otherwise.

func StringMaxLength

func StringMaxLength(l int) StringVerify

StringMaxLength verifies that a string must have a maximum length of "l".

func StringMinLength

func StringMinLength(l int) StringVerify

StringMinLength verifies that a string must have a minimum length of "l".

Jump to

Keyboard shortcuts

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