validator

package
v0.0.0-...-e43023e Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package validator provides struct tag validation and custom rule registration for Helix Cluster OS.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyValue       = errors.New("value must not be empty")
	ErrNilStruct        = errors.New("nil struct")
	ErrNotStruct        = errors.New("expected struct")
	ErrValidationFailed = errors.New("validation failed")
	ErrRequired         = errors.New("field is required")
	ErrInvalidEmail     = errors.New("invalid email")
	ErrInvalidUUID      = errors.New("invalid UUID")
	ErrOneOf            = errors.New("value not in allowed set")
	ErrMinExceeded      = errors.New("minimum exceeded")
	ErrMaxExceeded      = errors.New("maximum exceeded")
)

Functions

This section is empty.

Types

type RuleFunc

type RuleFunc func(value string) error

RuleFunc is a custom validation function.

type Validator

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

Validator holds validation rules.

func New

func New() *Validator

New creates a new Validator.

func (*Validator) IsValidID

func (v *Validator) IsValidID(id string) bool

IsValidID checks if id matches a simple alphanumeric pattern.

func (*Validator) NotEmpty

func (v *Validator) NotEmpty(s string) error

NotEmpty returns an error if s is empty.

func (*Validator) RegisterRule

func (v *Validator) RegisterRule(name string, fn RuleFunc)

RegisterRule registers a custom validation rule by name.

func (*Validator) ValidateStruct

func (v *Validator) ValidateStruct(s interface{}) error

ValidateStruct validates a struct using `validate` tags. Supported tags: required, min, max, email, uuid, oneof.

Jump to

Keyboard shortcuts

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