check

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(actual interface{}, expected []interface{}, msgAndArgs ...interface{}) error

Contains checks whether the actual value is contained in the expected list. This method returns an error with the provided message if the check fails.

func Equal

func Equal(actual, expected interface{}, msgAndArgs ...interface{}) error

Equal checks whether the arguments are equal (via reflect.DeepEqual). This method returns an error with the provided message if the check fails.

func False

func False(condition bool, msgAndArgs ...interface{}) error

False checks whether the condition is false. This method returns an error with the provided message if the check fails.

func GreaterThan

func GreaterThan(actual, expected interface{}, msgAndArgs ...interface{}) error

GreaterThan checks whether `actual` is greater than `expected`.

func GreaterThanOrEqualTo

func GreaterThanOrEqualTo(actual, expected interface{}, msgAndArgs ...interface{}) error

GreaterThanOrEqualTo checks whether `actual` is greater than or equal to `expected`.

func In

func In(actual string, expected []string, msgAndArgs ...interface{}) error

In checks whether the first argument is in the second argument. This method returns an error with the provided message if the check fails.

func LessThan

func LessThan(actual, expected interface{}, msgAndArgs ...interface{}) error

LessThan checks whether `actual` is less than `expected`.

func LessThanOrEqualTo

func LessThanOrEqualTo(actual, expected interface{}, msgAndArgs ...interface{}) error

LessThanOrEqualTo checks whether `actual` is less than or equal to `expected`.

func Match

func Match(actual string, regex string, msgAndArgs ...interface{}) error

Match checks whether the first argument matches the regular expression of the second argument. The method returns an error with the provided message if the check fails.

func NotEmpty

func NotEmpty(actual string, msgAndArgs ...interface{}) error

NotEmpty checks whether the first argument is empty string. The method returns an error with the provided message if the string is empty.

func Panic

func Panic(err error)

Panic panics if the error is not nil.

func True

func True(condition bool, msgAndArgs ...interface{}) error

True checks whether the condition is true. This method returns an error with the provided message if the check fails.

func TrueSilent

func TrueSilent(condition bool, msgAndArgs ...interface{}) error

TrueSilent checks whether the condition is true. This method returns an error containing only the provided message and nothing else if the check fails.

func Validate

func Validate(v interface{}) error

Validate returns an error if any of the provided validators have failed. The errors of all failed validators are combined into a single returned error.

Types

type Validatable

type Validatable interface {
	Validate() []error
}

Validatable is implemented by anything that has fields that should be validated.

type Validator

type Validator func() error

Validator returns an error if the validation fails and nil otherwise.

Jump to

Keyboard shortcuts

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