validate

package
v0.0.0-...-8d7bd48 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package validate contains the support for validating models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(val any) error

Check validates the provided model against it's declared tags.

func CheckID

func CheckID(id string) error

func IsFieldErrors

func IsFieldErrors(err error) bool

IsFieldErrors checks if an error of type FieldErrors exists.

func NewFieldsError

func NewFieldsError(field string, err error) error

NewFieldsError creates an fields error.

Types

type FieldError

type FieldError struct {
	Field string `json:"field"`
	Err   string `json:"error"`
}

FieldError is used to indicate an error with a specific request field.

type FieldErrors

type FieldErrors []FieldError

FieldErrors represents a collection of field errors.

func GetFieldErrors

func GetFieldErrors(err error) FieldErrors

GetFieldErrors returns a copy of the FieldErrors pointer.

func (FieldErrors) Error

func (fe FieldErrors) Error() string

Error implements the error interface.

func (FieldErrors) Fields

func (fe FieldErrors) Fields() map[string]string

Fields returns the fields that failed validation.

Jump to

Keyboard shortcuts

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