validate

package
v1.5.0-dev14 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsNoneOf added in v1.5.0

func ContainsNoneOf(s string, chars string, msg string, args ...any) error

ContainsNoneOf checks if the provided string contains none of the characters in the given set. It returns an error if the string contains any of the specified characters, using the provided message and arguments.

func IsEmpty

func IsEmpty[T any](s []T, msg string, args ...any) error

IsEmpty checks if the provided slice is empty. It returns an error if the slice is not empty, using the provided message and arguments. T is a generic type, allowing the function to work with slices of any type.

func IsGreaterOrEqual added in v1.3.2

func IsGreaterOrEqual[T math.Number](value, other T, msg string, args ...any) error

IsGreaterOrEqual checks if the first provided numeric value (of type T) is greater or equal to the second. It returns an error if the first value is less than the second, using the provided message and arguments. T is a generic type constrained to math.Number, allowing the function to work with various numeric types.

func IsGreaterOrEqualToZero added in v1.3.2

func IsGreaterOrEqualToZero[T math.Number](value T, msg string, args ...any) error

IsGreaterOrEqualToZero checks if the provided numeric value (of type T) is greater or equal to zero. It returns an error if the value is less than zero, using the provided message and arguments. T is a generic type constrained to math.Number, allowing the function to work with various numeric types.

func IsGreaterThan added in v1.3.2

func IsGreaterThan[T math.Number](value, other T, msg string, args ...any) error

IsGreaterThan checks if the first provided numeric value (of type T) is greater than the second. It returns an error if the first value is not greater than the second, using the provided message and arguments. T is a generic type constrained to math.Number, allowing the function to work with various numeric types.

func IsGreaterThanZero added in v1.2.1

func IsGreaterThanZero[T math.Number](value T, msg string, args ...any) error

IsGreaterThanZero checks if the provided numeric value (of type T) is greater than zero. It returns an error if the value is not greater than zero, using the provided message and arguments. T is a generic type constrained to math.Number, allowing the function to work with various numeric types.

func IsNotEmpty

func IsNotEmpty[T any](s []T, msg string, args ...any) error

IsNotEmpty checks if the provided slice is not empty. It returns an error if the slice is empty, using the provided message and arguments. T is a generic type, allowing the function to work with slices of any type.

func KeyNotInMap added in v1.5.0

func KeyNotInMap[K comparable, V any](key K, m map[K]V, msg string, args ...any) error

KeyNotInMap checks if the given key does not exist in the provided map. It returns an error if the key exists in the map, using the provided message and arguments. K is a generic type for the map key, which must be comparable. V is a generic type for the map value, which can be any type.

func NoNullChars added in v1.5.0

func NoNullChars(s string, msg string, args ...any) error

NoNullChars checks if the provided string contains no null characters (ASCII 0). It returns an error if the string contains any null characters, using the provided message and arguments.

func NoSpaces added in v1.5.0

func NoSpaces(s string, msg string, args ...any) error

NoSpaces checks if the provided string contains no whitespace characters. It returns an error if the string contains any whitespace, using the provided message and arguments.

func NotBlank added in v1.5.0

func NotBlank(s string, msg string, args ...any) error

NotBlank checks if the provided string is not empty or consisting only of whitespace. It returns an error if the string is blank, using the provided message and arguments.

func NotNil added in v1.5.0

func NotNil(value any, msg string, args ...any) error

NotNil checks if the provided value is not nil. Returns an error if the value is nil, using the provided message and arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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