validate

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MajorMinorVersionRegex = `^\d+\.\d+?$`
	FullVersionRegex       = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)` +
		`(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)` +
		`(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?` +
		`(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`
)

Variables

This section is empty.

Functions

func LabelValidators added in v0.97.0

func LabelValidators() []validator.Map

Types

type Validator

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

func CIDR added in v0.6.0

func CIDR() *Validator

func FileExists added in v0.38.0

func FileExists() *Validator

func IP

func IP(allowZeroAddress bool) *Validator

IP returns a validator that checks, if the given string is a valid IP address. The allowZeroAddress parameter defines, if 0.0.0.0, resp. [::] should be considered valid.

func IsLowercased added in v0.88.0

func IsLowercased() *Validator

IsLowercased returns a Validator that checks if all letters in the input string are lowercase. Examples: - "example": valid - "example123": valid, numbers are not affected by case - "exaMPle123": invalid

func MinorVersionNumber

func MinorVersionNumber() *Validator

func NoLeadingOrTrailingWhitespace added in v0.100.0

func NoLeadingOrTrailingWhitespace() *Validator

NoLeadingOrTrailingWhitespace returns a Validator that checks if the input string has leading or trailing whitespace. Examples: - "example": valid - "": valid, empty value - " example": invalid, leading whitespace - "example ": invalid, trailing whitespace

func NoSeparator

func NoSeparator() *Validator

func NoUUID added in v0.69.0

func NoUUID() *Validator

func NonLegacyProjectRole added in v0.26.0

func NonLegacyProjectRole() *Validator

func OnlyAllowedIfBoolEquals added in v0.113.0

func OnlyAllowedIfBoolEquals(target path.Expression, value *bool) *Validator

OnlyAllowedIfBoolEquals returns a Validator that prevents this string attribute from being set if the target bool attribute does not equal the specified value. If value is nil, no validation is performed.

func RFC3339SecondsOnly added in v0.4.0

func RFC3339SecondsOnly() *Validator

func RecordSet added in v0.13.0

func RecordSet() *Validator

func Rrule added in v0.21.0

func Rrule() *Validator

func UUID

func UUID() *Validator

func ValidDurationString added in v0.47.0

func ValidDurationString() *Validator

func ValidNoTrailingNewline added in v0.52.0

func ValidNoTrailingNewline() *Validator

ValidNoTrailingNewline returns a Validator that checks if the input string has no trailing newline character ("\n" or "\r\n"). If a trailing newline is present, a diagnostic error will be appended.

func VersionNumber added in v0.18.0

func VersionNumber() *Validator

func (*Validator) Description

func (v *Validator) Description(_ context.Context) string

func (*Validator) MarkdownDescription

func (v *Validator) MarkdownDescription(_ context.Context) string

func (*Validator) ValidateString

func (v *Validator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse)

Jump to

Keyboard shortcuts

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