validate

package
v0.0.0-...-a6f31fd Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSaltboxConfigs

func AllSaltboxConfigs(verbose bool) error

AllSaltboxConfigs validates all Saltbox configuration files using YAML schemas

func SetVerbose

func SetVerbose(v bool)

SetVerbose sets verbose mode for debugging

Types

type APIValidationResult

type APIValidationResult struct {
	Name  string
	Error error
}

APIValidationResult holds the result of an async API validation

type AsyncAPIValidator

type AsyncAPIValidator func(value any, config map[string]any) error

AsyncAPIValidator function type for async API validation

type AsyncValidationContext

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

AsyncValidationContext manages async API validations

func NewAsyncValidationContext

func NewAsyncValidationContext() *AsyncValidationContext

NewAsyncValidationContext creates a new async validation context

func (*AsyncValidationContext) AddAPIValidation

func (ctx *AsyncValidationContext) AddAPIValidation(name string, validator AsyncAPIValidator, value any, config map[string]any)

AddAPIValidation adds an async API validation to be executed

func (*AsyncValidationContext) Wait

func (ctx *AsyncValidationContext) Wait() []error

Wait waits for all async validations to complete and returns any errors

type CustomValidator

type CustomValidator func(value any, config map[string]any) error

CustomValidator function type for custom validation

type Schema

type Schema struct {
	Rules map[string]*SchemaRule
}

Schema holds validation rules

func LoadSchema

func LoadSchema(schemaPath string) (*Schema, error)

LoadSchema loads a YAML schema file

func (*Schema) Validate

func (s *Schema) Validate(config map[string]any) error

Validate validates a configuration against the schema

func (*Schema) ValidateStructure

func (s *Schema) ValidateStructure(config map[string]any) error

ValidateStructure performs lightweight structure validation (checks for unknown fields, required fields, but skips type checking)

func (*Schema) ValidateWithTypeFlexibility

func (s *Schema) ValidateWithTypeFlexibility(config map[string]any) error

ValidateWithTypeFlexibility performs full validation including custom validators but ignores type mismatches

func (*Schema) ValidateWithTypeFlexibilityAsync

func (s *Schema) ValidateWithTypeFlexibilityAsync(config map[string]any) (*AsyncValidationContext, error)

ValidateWithTypeFlexibilityAsync performs validation with async API checks

type SchemaRule

type SchemaRule struct {
	Type             string                 `yaml:"type"`
	Required         bool                   `yaml:"required"`
	Format           string                 `yaml:"format"`
	MinLength        int                    `yaml:"min_length"`
	MaxLength        int                    `yaml:"max_length"`
	NotEquals        any                    `yaml:"not_equals"`
	RequiredWith     []string               `yaml:"required_with"`
	RequiredWhenTrue []string               `yaml:"required_when_true"`
	ValidateWhenTrue []string               `yaml:"validate_when_true"`
	CustomValidator  string                 `yaml:"custom_validator"`
	Properties       map[string]*SchemaRule `yaml:"properties"`
	Items            *SchemaRule            `yaml:"items"` // For array validation
	// Fields for example config generation
	Description string `yaml:"description"` // Comment to display above the section
	Example     any    `yaml:"example"`     // Example value for this field
}

SchemaRule represents a validation rule for a field

Jump to

Keyboard shortcuts

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