validator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package validator provides configuration validation functionality using the go-playground/validator library. It supports both struct tag validation and custom validation through the Validator interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(v any) error

Validate performs comprehensive validation on the provided value. It first runs struct tag validation using the go-playground/validator library, then checks if the value implements the Validator interface for custom validation.

The validation process: 1. Checks for nil values 2. Performs struct tag validation (required, format, etc.) 3. Calls custom Validate() method if the type implements Validator interface

Returns an error if any validation step fails.

Types

type Validator

type Validator interface {
	// Validate performs custom validation and returns an error if validation fails
	Validate() error
}

Validator defines an interface for custom validation logic. Types implementing this interface can provide their own validation rules beyond the standard struct tag validation.

Jump to

Keyboard shortcuts

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