validator

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WarningTypeCode indicates a warning is being returned.
	WarningTypeCode = 100
	// ErrorTypeCode indicates an error is being returned.
	ErrorTypeCode = 500
)

All code responses can be used to differentiate errors for different handling by the consumer

Variables

View Source
var Nop = &validate.Result{}

Nop is used for no-op validator results.

Functions

This section is empty.

Types

type ObjectValidator

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

ObjectValidator provides a mechanism for grouping various validators for a given object type.

func New

func New(validators ...Validator) *ObjectValidator

New returns a new ObjectValidator.

func (*ObjectValidator) AddToChain

func (o *ObjectValidator) AddToChain(validators ...Validator)

AddToChain adds the given validators to the internal validation chain for the ObjectValidator.

func (*ObjectValidator) Validate

func (o *ObjectValidator) Validate(ctx context.Context, data any) *validate.Result

Validate implements the validator.Validator interface, providing a way to validate more than just the strict schema for a given runtime.Object.

type UsingContext

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

UsingContext allows us to use kube-openapi validators without context usage to conform our interfaces that require it.

func NewUsingContext

func NewUsingContext(k kubeValidator) *UsingContext

NewUsingContext returns a new validator that uses the provided kubeValidator with no context.

func (*UsingContext) Validate

func (uc *UsingContext) Validate(_ context.Context, data any) *validate.Result

Validate calls the underlying kubeValidator's Validate method without a context.

type Validation

type Validation struct {
	TypeCode int32
	Message  string
	Name     string
}

Validation represents a failure of a file condition.

func (*Validation) Code

func (e *Validation) Code() int32

Code returns the code corresponding to the MetaValidation.

func (*Validation) Error

func (e *Validation) Error() string

type Validator

type Validator interface {
	Validate(ctx context.Context, data any) *validate.Result
}

A Validator validates data and returns a validation result.

Jump to

Keyboard shortcuts

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