validation

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureNonNil

func EnsureNonNil(value interface{}, results ResultCollector)

EnsureNonNil adds a validation failure to the validation.ResultCollector, in case the value is nil

func Validate

func Validate(newObject, oldObject runtime.Object, validators ...Validator) ([]v1.StatusCause, error)

Validate validates the provided object using the provided Validator

Types

type ResultCollector

type ResultCollector interface {
	// Failures returns the collected v1.StatusCause each representing a validation error
	Failures() []v1.StatusCause
	// AddFailure adds a message denoting the a failed validation the current field
	AddFailure(message string)
	// AppendField appends the provided suffix to the field and returns a new ResultCollector for the field
	AppendField(suffix string) ResultCollector
}

ResultCollector denotes a collector for failures which can be used descending an object hierarchy

func NewResultCollector

func NewResultCollector() ResultCollector

type Validator

type Validator interface {
	kewl.NamedObject
	codec.SchemeExtension
	// Validate validates the runtime.Object representation collecting the result using the ResultCollector or yielding an
	// error if the validator fails to run
	Validate(oldObject, newObject runtime.Object, results ResultCollector) error
}

Validator denotes a validator for any interface{}

Jump to

Keyboard shortcuts

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