validation

package
v0.6.0-alpha.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrors

func AssertErrors(t *testing.T, err error, key, detail string, v *Validator)

AssertErrors is a helper function to assert that the validation errors are as expected.

func AssertValidationErrs

func AssertValidationErrs(t *testing.T, errs ValidationErrors, key string, detail string)

func IsValidWorkflowName

func IsValidWorkflowName(workflowName string) error

func NewValidationError

func NewValidationError(key, detail string) error

Types

type ValidationError

type ValidationError struct {
	Field  string
	Detail string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func (ValidationErrors) Error

func (ve ValidationErrors) Error() string

Add error interface implementation for ValidationErrors

type Validator

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

Validator wraps a validator instance and a translator.

func NewValidator

func NewValidator() (*Validator, error)

NewValidator creates a new Validator with English translations registered.

func (*Validator) ParseValidationErrors

func (v *Validator) ParseValidationErrors(err error) ValidationErrors

ParseValidationErrors parses a raw validation error and returns a slice of ValidationErrors.

func (*Validator) RegisterCustomTranslation

func (v *Validator) RegisterCustomTranslation(tag, msg string) error

RegisterCustomTranslation registers a custom translation for a given tag.

func (*Validator) Struct

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

Struct validates a struct and returns translated errors if any.

func (*Validator) Translator

func (v *Validator) Translator() ut.Translator

Translator returns the underlying translator if you need direct access.

func (*Validator) Validate

func (v *Validator) Validate() *validator.Validate

Validate returns the underlying *validator.Validate instance if you need it directly.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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