checker

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package checker provides a way to run checks against a variadic number of inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidateFunc

type ValidateFunc func(any) error

ValidateFunc is a function type that takes an input of any type and returns an error if the validation fails.

type Validator

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

Validator is a struct that holds a list of checks to be performed.

func NewValidator

func NewValidator(c ...ValidatorCheck) Validator

NewValidator creates a new Validator with the given checks.

func (Validator) AddChecks

func (v Validator) AddChecks(c ...ValidatorCheck) Validator

AddChecks adds additional checks to the Validator.

func (Validator) Validate

func (v Validator) Validate(resource any) error

Validate runs all the checks in the Validator against the provided resource.

type ValidatorCheck

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

ValidatorCheck is a struct that holds the name and function of a check to be performed. The function should return an error if the check fails. Use closures to capture the context of the check, such as the resource type or other parameters.

func NewValidatorCheck

func NewValidatorCheck(name string, f ValidateFunc) ValidatorCheck

NewValidatorCheck creates a new ValidatorCheck with the given name and function.

Jump to

Keyboard shortcuts

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