validation

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 17 Imported by: 1,566

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

func AllDiag added in v2.29.0

AllDiag returns a SchemaValidateDiagFunc which tests if the provided value passes all provided SchemaValidateDiagFunc

func Any

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

func AnyDiag added in v2.29.0

AnyDiag returns a SchemaValidateDiagFunc which tests if the provided value passes any of the provided SchemaValidateDiagFunc

func FloatAtLeast

func FloatAtLeast(min float64) schema.SchemaValidateFunc

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

func FloatAtMost

func FloatAtMost(max float64) schema.SchemaValidateFunc

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

func FloatBetween

func FloatBetween(min, max float64) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) (warnings []string, errors []error)

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

func IsCIDRNetwork

func IsCIDRNetwork(min, max int) schema.SchemaValidateFunc

IsCIDRNetwork returns a SchemaValidateFunc which tests if the provided value is of type string, is in valid Value network notation, and has significant bits between min and max (inclusive)

func IsDayOfTheWeek

func IsDayOfTheWeek(ignoreCase bool) schema.SchemaValidateFunc

IsDayOfTheWeek is 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) (warnings []string, errors []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) (warnings []string, errors []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) (warnings []string, errors []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) (warnings []string, errors []error)

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

func IsMACAddress

func IsMACAddress(i interface{}, k string) (warnings []string, errors []error)

IsMACAddress is a SchemaValidateFunc which tests if the provided value is of type string and a valid MAC address

func IsMonth

func IsMonth(ignoreCase bool) schema.SchemaValidateFunc

IsMonth is 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) (warnings []string, errors []error)

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

func IsPortNumberOrZero

func IsPortNumberOrZero(i interface{}, k string) (warnings []string, errors []error)

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

func IsRFC3339Time

func IsRFC3339Time(i interface{}, k string) (warnings []string, errors []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, errors []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, errors []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) schema.SchemaValidateFunc

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) (warnings []string, errors []error)

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

func ListOfUniqueStrings

func ListOfUniqueStrings(i interface{}, k string) (warnings []string, errors []error)

ListOfUniqueStrings is a ValidateFunc that ensures a list has no duplicate items in it. It's useful for when a list is needed over a set because order matters, yet the items still need to be unique.

func MapKeyLenBetween

func MapKeyLenBetween(min, max int) schema.SchemaValidateDiagFunc

MapKeyLenBetween returns a SchemaValidateDiagFunc which tests if the provided value is of type map and the length of all keys are between min and max (inclusive)

func MapKeyMatch

func MapKeyMatch(r *regexp.Regexp, message string) schema.SchemaValidateDiagFunc

MapKeyMatch returns a SchemaValidateDiagFunc which tests if the provided value is of type map and all keys match a given regexp. Optionally an error message can be provided to return something friendlier than "expected to match some globby regexp".

func MapValueLenBetween

func MapValueLenBetween(min, max int) schema.SchemaValidateDiagFunc

MapValueLenBetween returns a SchemaValidateDiagFunc which tests if the provided value is of type map and the length of all values are between min and max (inclusive)

func MapValueMatch

func MapValueMatch(r *regexp.Regexp, message string) schema.SchemaValidateDiagFunc

MapValueMatch returns a SchemaValidateDiagFunc which tests if the provided value is of type map and all values match a given regexp. Optionally an error message can be provided to return something friendlier than "expected to match some globby regexp".

func NoZeroValues

func NoZeroValues(i interface{}, k string) (s []string, es []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 StringDoesNotContainAny

func StringDoesNotContainAny(chars string) schema.SchemaValidateFunc

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

func StringDoesNotMatch

func StringDoesNotMatch(r *regexp.Regexp, message string) schema.SchemaValidateFunc

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

func StringInSlice

func StringInSlice(valid []string, ignoreCase bool) schema.SchemaValidateFunc

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) (warnings []string, errors []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) (warnings []string, errors []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) (warnings []string, errors []error)

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

func StringIsWhiteSpace

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

StringIsWhiteSpace is a ValidateFunc that ensures a string is composed of entirely whitespace

func StringLenBetween

func StringLenBetween(min, max int) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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) schema.SchemaValidateFunc

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

func ToDiagFunc added in v2.4.0

ToDiagFunc is a wrapper for legacy schema.SchemaValidateFunc converting it to schema.SchemaValidateDiagFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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