package content
import "k8s.io/apimachinery/pkg/api/validate/content"
Index ¶
- Constants
- Variables
- func EmptyError() string
- func IsCIdentifier(value string) []string
- func IsDNS1123Label(value string) []string
- func IsDNS1123Subdomain(value string) []string
- func IsDNS1123SubdomainCaseless(value string) []string
- func IsDecimalInteger(value string) []string
- func IsLabelKey(value string) []string
- func IsLabelValue(value string) []string
- func MaxLenError(length int) string
- func MinError[T constraints.Integer](min T) string
- func NEQError[T any](disallowed T) string
- func RegexError(msg string, re string, examples ...string) string
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 ¶
IsCIdentifier tests for a string that conforms the definition of an identifier in C. This checks the format, but not the length.
func IsDNS1123Label ¶
IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).
func IsDNS1123Subdomain ¶
IsDNS1123Subdomain tests for a string that conforms to the definition of a subdomain in DNS (RFC 1123) lowercase.
func IsDNS1123SubdomainCaseless ¶
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 ¶
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 ¶
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 ¶
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 MaxLenError ¶
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 ¶
NEQError returns a string explanation of a "must not be equal to" validation failure.
func RegexError ¶
RegexError returns a string explanation of a regex validation failure.
Source Files ¶
decimal_int.go dns.go errors.go identifier.go kube.go
- Version
- v0.35.3
- Published
- Dec 4, 2025
- Platform
- windows/amd64
- Imports
- 5 packages
- Last checked
- 8 minutes ago –
Tools for package owners.