validator

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package validator provides validation utilities for MCP tool arguments and other structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arguments

func Arguments(s interface{}) error

Arguments enforces `required` and `enum` struct tags for validation. Usage: if err := validator.Arguments(args); err != nil { ... }

Types

type Validator

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

Validator helps validate tool arguments using a fluent interface.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new validator.

func (*Validator) Error

func (v *Validator) Error() error

Error returns a combined error message if there are any validation errors.

func (*Validator) Errors

func (v *Validator) Errors() []string

Errors returns any validation errors.

func (*Validator) HasErrors

func (v *Validator) HasErrors() bool

HasErrors checks if there are any validation errors.

func (*Validator) Max

func (v *Validator) Max(field string, value, max int) *Validator

Max checks if a numeric field meets maximum value requirement.

func (*Validator) MaxLength

func (v *Validator) MaxLength(field string, value string, max int) *Validator

MaxLength checks if a string field meets maximum length requirement.

func (*Validator) Min

func (v *Validator) Min(field string, value, min int) *Validator

Min checks if a numeric field meets minimum value requirement.

func (*Validator) MinLength

func (v *Validator) MinLength(field string, value string, min int) *Validator

MinLength checks if a string field meets minimum length requirement.

func (*Validator) Required

func (v *Validator) Required(field string, value interface{}) *Validator

Required checks if a field is present and not empty.

Jump to

Keyboard shortcuts

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