validation

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 12 Imported by: 15

Documentation

Overview

Package validation defines apimachinery user-defined validations.

Index

Constants

View Source
const DNS1123LabelMaxLength int = 63

DNS1123LabelMaxLength is a label's max length in DNS (RFC 1123).

View Source
const DNS1123SubdomainMaxLength int = 253

DNS1123SubdomainMaxLength is a subdomain's max length in DNS (RFC 1123).

View Source
const LabelValueMaxLength int = 63

LabelValueMaxLength is a label's max length.

Variables

This section is empty.

Functions

func EmptyError

func EmptyError() string

EmptyError returns a string explanation of a "must not be empty" validation failure.

func InclusiveRangeError

func InclusiveRangeError(lo, hi int) string

InclusiveRangeError returns a string explanation of a numeric "must be between" validation failure.

func IsDNS1123Label

func IsDNS1123Label(value string) []string

IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).

func IsDNS1123Subdomain

func IsDNS1123Subdomain(value string) []string

IsDNS1123Subdomain tests for a string that conforms to the definition of a subdomain in DNS (RFC 1123).

func IsInRange

func IsInRange(value int, min int, max int) []string

IsInRange tests that the argument is in an inclusive range.

func IsQualifiedName

func IsQualifiedName(value string) []string

IsQualifiedName tests whether the value passed is what IAM calls a "qualified name". This is a format used in various places throughout the system. If the value is not valid, a list of error strings is returned. Otherwise an empty list (or nil) is returned.

func IsValidIP

func IsValidIP(value string) []string

IsValidIP tests that the argument is a valid IP address.

func IsValidIPv4Address

func IsValidIPv4Address(fldPath *field.Path, value string) field.ErrorList

IsValidIPv4Address tests that the argument is a valid IPv4 address.

func IsValidIPv6Address

func IsValidIPv6Address(fldPath *field.Path, value string) field.ErrorList

IsValidIPv6Address tests that the argument is a valid IPv6 address.

func IsValidLabelValue

func IsValidLabelValue(value string) []string

IsValidLabelValue tests whether the value passed is a valid label value. If the value is not valid, a list of error strings is returned. Otherwise an empty list (or nil) is returned.

func IsValidPassword

func IsValidPassword(password string) error

IsValidPassword validate password.

func IsValidPercent

func IsValidPercent(percent string) []string

IsValidPercent checks that string is in the form of a percentage.

func IsValidPortNum

func IsValidPortNum(port int) []string

IsValidPortNum tests that the argument is a valid, non-zero port number.

func MaxLenError

func MaxLenError(length int) string

MaxLenError returns a string explanation of a "string too long" validation failure.

func RegexError

func RegexError(msg string, fmt string, examples ...string) string

RegexError returns a string explanation of a regex validation failure.

Types

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator is a custom validator for configs.

func NewValidator

func NewValidator(data interface{}) *Validator

NewValidator creates a new Validator.

func (*Validator) Validate

func (v *Validator) Validate() field.ErrorList

Validate validates config for errors and returns an error (it can be casted to ValidationErrors, containing a list of errors inside). When error is printed as string, it will automatically contains the full list of validation errors.

Directories

Path Synopsis
Package field implements field path functions when do validation.
Package field implements field path functions when do validation.

Jump to

Keyboard shortcuts

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