validate

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

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 CheckConfig

func CheckConfig(key, value string) error

CheckConfig validates that the Config format is valid.

func CheckEmail

func CheckEmail(email string) bool

CheckEmail validates that the string is an email.

func CheckID

func CheckID(id string) error

CheckID validates that the format of an id is valid.

func CheckPostCmds

func CheckPostCmds(postCmds string) error

CheckPostCmds validates that the PostCmds format is valid.

func CheckSplitRule

func CheckSplitRule(splitRule string) error

CheckSplitRule validates that the SplitRule format 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 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