validate

package
v0.0.0-...-40cf777 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 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 interface{}) error

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

func CheckID

func CheckID(id string) error

CheckID validates that the format of an id is valid.

func GenerateID

func GenerateID() string

GenerateID generate a unique id for entities.

func IsFieldErrors

func IsFieldErrors(err error) bool

IsFieldErrors checks if an error of type FieldErrors exists.

Types

type FieldError

type FieldError struct {
	Field string `json:"field"`
	Error 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 implments 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