validation

package
v2.96.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

All returns a SchemaValidateFunc which tests if the provided value passes all provided SchemaValidateFunc lint:ignore SA1019 SDKv2 migration - staticcheck's own linter directives are currently being ignored under golanci-lint

func Any

Any returns a SchemaValidateFunc which tests if the provided value passes any of the provided SchemaValidateFunc

func FloatAtLeast

func FloatAtLeast(min float64) func(interface{}, string) ([]string, []error)

FloatAtLeast returns a SchemaValidateFunc which tests if the provided value is of type float and is at least min (inclusive)

func FloatBetween

func FloatBetween(min, max float64) func(interface{}, string) ([]string, []error)

FloatBetween returns a SchemaValidateFunc which tests if the provided value is of type float64 and is between min and max (inclusive).

func IntAtLeast

func IntAtLeast(min int) func(interface{}, string) ([]string, []error)

IntAtLeast returns a SchemaValidateFunc which tests if the provided value is of type int and is at least min (inclusive)

func IntAtMost

func IntAtMost(max int) func(interface{}, string) ([]string, []error)

IntAtMost returns a SchemaValidateFunc which tests if the provided value is of type int and is at most max (inclusive)

func IntBetween

func IntBetween(min, max int) func(interface{}, string) ([]string, []error)

IntBetween returns a SchemaValidateFunc which tests if the provided value is of type int and is between min and max (inclusive)

func IntDivisibleBy

func IntDivisibleBy(divisor int) func(interface{}, string) ([]string, []error)

IntDivisibleBy returns a SchemaValidateFunc which tests if the provided value is of type int and is divisible by a given number

func IntInSlice

func IntInSlice(valid []int) func(interface{}, string) ([]string, []error)

IntInSlice returns a SchemaValidateFunc which tests if the provided value is of type int and matches the value of an element in the valid slice

func IntNotInSlice

func IntNotInSlice(valid []int) func(interface{}, string) ([]string, []error)

IntNotInSlice returns a SchemaValidateFunc which tests if the provided value is of type int and matches the value of an element in the valid slice

func IsCIDR

func IsCIDR(i interface{}, k string) ([]string, []error)

IsCIDR is a SchemaValidateFunc which tests if the provided value is of type string and a valid CIDR

func IsDayOfTheWeek

func IsDayOfTheWeek(ignoreCase bool) func(interface{}, string) ([]string, []error)

IsDayOfTheWeek id a SchemaValidateFunc which tests if the provided value is of type string and a valid english day of the week

func IsIPAddress

func IsIPAddress(i interface{}, k string) ([]string, []error)

IsIPAddress is a SchemaValidateFunc which tests if the provided value is of type string and is a single IP (v4 or v6)

func IsIPv4Address

func IsIPv4Address(i interface{}, k string) ([]string, []error)

IsIPv4Address is a SchemaValidateFunc which tests if the provided value is of type string and a valid IPv4 address

func IsIPv4Range

func IsIPv4Range(i interface{}, k string) ([]string, []error)

IsIPv4Range is a SchemaValidateFunc which tests if the provided value is of type string, and in valid IP range

func IsIPv6Address

func IsIPv6Address(i interface{}, k string) ([]string, []error)

IsIPv6Address is a SchemaValidateFunc which tests if the provided value is of type string and a valid IPv6 address

func IsMonth

func IsMonth(ignoreCase bool) func(interface{}, string) ([]string, []error)

IsMonth id a SchemaValidateFunc which tests if the provided value is of type string and a valid english month

func IsPortNumber

func IsPortNumber(i interface{}, k string) ([]string, []error)

IsPortNumber is a SchemaValidateFunc which tests if the provided value is of type string and a valid TCP Port Number

func IsRFC3339Time

func IsRFC3339Time(i interface{}, k string) ([]string, []error)

IsRFC3339Time is a SchemaValidateFunc which tests if the provided value is of type string and a valid RFC33349Time

func IsURLWithHTTPS

func IsURLWithHTTPS(i interface{}, k string) ([]string, []error)

IsURLWithHTTPS is a SchemaValidateFunc which tests if the provided value is of type string and a valid HTTPS URL

func IsURLWithHTTPorHTTPS

func IsURLWithHTTPorHTTPS(i interface{}, k string) ([]string, []error)

IsURLWithHTTPorHTTPS is a SchemaValidateFunc which tests if the provided value is of type string and a valid HTTP or HTTPS URL

func IsURLWithScheme

func IsURLWithScheme(validSchemes []string) func(interface{}, string) ([]string, []error)

IsURLWithScheme is a SchemaValidateFunc which tests if the provided value is of type string and a valid URL with the provided schemas

func IsUUID

func IsUUID(i interface{}, k string) ([]string, []error)

IsUUID is a ValidateFunc that ensures a string can be parsed as UUID

func NoZeroValues

func NoZeroValues(i interface{}, k string) ([]string, []error)

NoZeroValues is a SchemaValidateFunc which tests if the provided value is not a zero value. It's useful in situations where you want to catch explicit zero values on things like required fields during validation.

func None

func None(validators map[string]func(interface{}, string) ([]string, []error)) func(interface{}, string) ([]string, []error)

None returns a SchemaValidateFunc which tests if the provided value returns errors for all of the provided SchemaValidateFunc

func StringDoesNotContainAny

func StringDoesNotContainAny(chars string) func(interface{}, string) ([]string, []error)

StringDoesNotContainAny returns a SchemaValidateFunc which validates that the provided value does not contain any of the specified Unicode code points in chars.

func StringInSlice

func StringInSlice(valid []string, ignoreCase bool) func(interface{}, string) ([]string, []error)

StringInSlice returns a SchemaValidateFunc which tests if the provided value is of type string and matches the value of an element in the valid slice will test with in lower case if ignoreCase is true

func StringIsBase64

func StringIsBase64(i interface{}, k string) ([]string, []error)

StringIsBase64 is a ValidateFunc that ensures a string can be parsed as Base64

func StringIsEmpty

func StringIsEmpty(i interface{}, k string) ([]string, []error)

StringIsEmpty is a ValidateFunc that ensures a string has no characters

func StringIsJSON

func StringIsJSON(i interface{}, k string) ([]string, []error)

StringIsJSON is a SchemaValidateFunc which tests to make sure the supplied string is valid JSON.

func StringIsNotEmpty

func StringIsNotEmpty(i interface{}, k string) ([]string, []error)

StringIsNotEmpty is a ValidateFunc that ensures a string is not empty

func StringIsNotWhiteSpace

func StringIsNotWhiteSpace(i interface{}, k string) ([]string, []error)

StringIsNotWhiteSpace is a ValidateFunc that ensures a string is not empty or consisting entirely of whitespace characters

func StringIsValidRegExp

func StringIsValidRegExp(i interface{}, k string) ([]string, []error)

StringIsValidRegExp returns a SchemaValidateFunc which tests to make sure the supplied string is a valid regular expression.

func StringLenBetween

func StringLenBetween(min, max int) func(interface{}, string) ([]string, []error)

StringLenBetween returns a SchemaValidateFunc which tests if the provided value is of type string and has length between min and max (inclusive)

func StringMatch

func StringMatch(r *regexp.Regexp, message string) func(interface{}, string) ([]string, []error)

StringMatch returns a SchemaValidateFunc which tests if the provided value matches a given regexp. Optionally an error message can be provided to return something friendlier than "must match some globby regexp".

func StringNotInSlice

func StringNotInSlice(invalid []string, ignoreCase bool) func(interface{}, string) ([]string, []error)

StringNotInSlice returns a SchemaValidateFunc which tests if the provided value is of type string and does not match the value of any element in the invalid slice will test with in lower case if ignoreCase is true

Types

This section is empty.

Jump to

Keyboard shortcuts

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