validation

package
Version: v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MPL-2.0 Imports: 14 Imported by: 152

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 Any

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

func CIDRNetwork deprecated

func CIDRNetwork(min, max int) schema.SchemaValidateFunc

CIDRNetwork 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)

Deprecated: use IsCIDRNetwork instead

func FloatAtLeast added in v1.4.0

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 added in v1.4.0

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 IPRange deprecated

func IPRange() schema.SchemaValidateFunc

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

Deprecated: use IsIPv4Range instead

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

func IsDayOfTheWeek(ignoreCase bool) schema.SchemaValidateFunc

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

func IsIPAddress added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

func IsMonth(ignoreCase bool) schema.SchemaValidateFunc

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

func IsPortNumber added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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 added in v1.5.0

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 added in v1.6.0

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 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 SingleIP deprecated

func SingleIP() schema.SchemaValidateFunc

SingleIP returns a SchemaValidateFunc which tests if the provided value is of type string, and in valid single Value notation

Deprecated: use IsIPAddress instead

func StringDoesNotContainAny added in v1.3.0

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 added in v1.4.0

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 added in v1.5.0

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 added in v1.5.0

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

StringIsEmpty is a ValidateFunc that ensures a string has no characters

func StringIsJSON added in v1.6.0

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 added in v1.5.0

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

StringIsNotEmpty is a ValidateFunc that ensures a string is not empty

func StringIsNotWhiteSpace added in v1.5.0

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 added in v1.6.0

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 added in v1.5.0

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 added in v1.8.0

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 ValidateJsonString deprecated

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

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

Deprecated: use StringIsJSON instead

func ValidateListUniqueStrings deprecated

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

ValidateListUniqueStrings 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.

Deprecated: use ListOfUniqueStrings

func ValidateRFC3339TimeString deprecated

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

ValidateRFC3339TimeString is a ValidateFunc that ensures a string parses as time.RFC3339 format

Deprecated: use IsRFC3339Time() instead

func ValidateRegexp deprecated

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

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

Deprecated: use StringIsValidRegExp instead

Types

This section is empty.

Jump to

Keyboard shortcuts

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