apimachineryk8s.io/apimachinery/pkg/api/validate/content Index | Files

package content

import "k8s.io/apimachinery/pkg/api/validate/content"

Index

Constants

const DNS1123LabelMaxLength int = 63

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

const DNS1123SubdomainMaxLength int = 253

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

const LabelValueMaxLength int = 63

LabelValueMaxLength is a label's max length

Variables

var IsQualifiedName = IsLabelKey

IsQualifiedName tests whether the value passed is what Kubernetes calls a "qualified name", which is the same as a label key.

Deprecated: use IsLabelKey instead.

Functions

func EmptyError

func EmptyError() string

EmptyError returns a string explanation of an "empty string" validation.

func IsCIdentifier

func IsCIdentifier(value string) []string

IsCIdentifier tests for a string that conforms the definition of an identifier in C. This checks the format, but not the length.

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) lowercase.

func IsDNS1123SubdomainCaseless

func IsDNS1123SubdomainCaseless(value string) []string

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

Deprecated: API validation should never be caseless. Caseless validation is a vector for bugs and failed uniqueness assumptions. For example, names like "foo.com" and "FOO.COM" are both accepted as valid, but they are typically not treated as equal by consumers (e.g. CSI and DRA driver names). This fails the "least surprise" principle and can cause inconsistent behaviors.

Note: This allows uppercase names but is not caseless — uppercase and lowercase are treated as different values. Use IsDNS1123Subdomain for strict, lowercase validation instead.

func IsDecimalInteger

func IsDecimalInteger(value string) []string

IsDecimalInteger validates that a string represents a decimal integer in strict canonical form. This means the string must be formatted exactly as a human would naturally write an integer, without any programming language conventions like leading zeros, plus signs, or alternate bases.

valid values:"0" or Non-zero integers (i.e., "123", "-456") where the first digit is 1-9, followed by any digits 0-9.

This validator is stricter than strconv.ParseInt, which accepts leading zeros values (i.e, "0700") and interprets them as decimal 700, potentially causing confusion with octal notation.

func IsLabelKey

func IsLabelKey(value string) []string

IsLabelKey tests whether the value passed is a valid label key. This format is used to validate many fields in the Kubernetes API. Label keys consist of an optional prefix and a name, separated by a '/'. If the value is not valid, a list of error strings is returned. Otherwise, an empty list (or nil) is returned.

func IsLabelValue

func IsLabelValue(value string) []string

IsLabelValue 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 IsPathSegmentName

func IsPathSegmentName(name string) []string

IsPathSegmentName validates the name can be safely encoded as a path segment.

Note that, for historical reason, this function does not check for empty strings or impose a limit on the length of the name.

func IsPathSegmentPrefix

func IsPathSegmentPrefix(name string) []string

IsPathSegmentPrefix validates the name can be used as a prefix for a name which will be encoded as a path segment It does not check for exact matches with disallowed names, since an arbitrary suffix might make the name valid.

Note that, for historical reason, this function does not check for empty strings or impose a limit on the length of the name.

func MaxLenError

func MaxLenError(length int) string

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

func MinError

func MinError[T constraints.Integer](min T) string

MinError returns a string explanation of a "must be greater than or equal" validation failure.

func NEQError

func NEQError[T any](disallowed T) string

NEQError returns a string explanation of a "must not be equal to" validation failure.

func RegexError

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

RegexError returns a string explanation of a regex validation failure.

Source Files

decimal_int.go dns.go errors.go identifier.go kube.go path.go

Version
v0.36.0-alpha.2
Published
Feb 24, 2026
Platform
darwin/amd64
Imports
5 packages
Last checked
37 seconds ago

Tools for package owners.