validator

package
v0.0.0-...-4f50f5e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleValidationError

func HandleValidationError(log *zap.Logger, err error) []string

HandleValidationError takes the validation error and read the failed fields

Types

type Validator

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

Validator has functions for validating struct and variables

func New

func New(log *zap.Logger) *Validator

New returns a new Validator

func (*Validator) AddCustomValidator

func (v *Validator) AddCustomValidator(name string, f validatorFn) error

AddCustomValidator adds a custom validator tag

Note :- This method is not thread-safe it is intended that these all be registered prior to any validation

func (*Validator) AddStringModifier

func (v *Validator) AddStringModifier(name string, fn stringModifierFn) error

AddStringModifier adds a tag that modifies the string value

Note :- This method is not thread-safe it is intended that these all be registered prior to any validation

func (*Validator) AddStructLevelValidation

func (v *Validator) AddStructLevelValidation(fn validator.StructLevelFunc, structType interface{})

AddStructLevelValidation adds a custom struct level validation

Note :- This method is not thread-safe it is intended that these all be registered prior to any validation

func (*Validator) IsValidStruct

func (v *Validator) IsValidStruct(data interface{}) []string

IsValidStruct validates a struct and returns a list of invalid fields or nil

Jump to

Keyboard shortcuts

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