validation

package
v0.0.0-...-36c55c0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package validation provides a shared validator instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtLeastOneField

func AtLeastOneField(
	v any,
) (string, bool)

AtLeastOneField checks that at least one exported pointer, slice, or map field in the struct is non-nil, or that at least one non-pointer field is non-zero. Returns an error message and false if all fields are nil/zero (i.e., the update body is empty).

func Instance

func Instance() *validator.Validate

Instance returns the shared validator for registering custom validators.

func RegisterTargetValidator

func RegisterTargetValidator(
	lister AgentLister,
)

RegisterTargetValidator registers the valid_target custom validator and sets the AgentLister it uses. Call this at API server startup after the job client is created, or in test SetupSuite to inject a mock.

func Struct

func Struct(
	v any,
) (string, bool)

Struct validates a struct and returns the error message and false if invalid.

func Var

func Var(
	field any,
	tag string,
) (string, bool)

Var validates a single variable against a tag string and returns the error message and false if invalid. This is useful for path parameters that oapi-codegen does not generate validate tags for in strict-server mode.

Types

type AgentLister

type AgentLister func(ctx context.Context) ([]AgentTarget, error)

AgentLister returns active agents with their hostnames and labels.

type AgentTarget

type AgentTarget struct {
	Hostname string
	Labels   map[string]string
}

AgentTarget holds the routing-relevant fields of an active agent.

Jump to

Keyboard shortcuts

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