gokay

package
v0.0.0-...-25e1d4e Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package gokay is used for defining validation functions that are called in generated Validate functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBCP47

func IsBCP47(s *string) error

func IsHex

func IsHex(s *string) error

IsHex validates that the given string is a hex value

func IsUUID

func IsUUID(s *string) error

IsUUID validates that the given string is a UUID value

func LengthSlice

func LengthSlice(expected int64, actual int64) error

LengthSlice not yet implemented

func LengthString

func LengthString(expected int64, str *string) error

LengthString checks if the value of a string pointer has a length of exactly 'expected'

func MinLengthString

func MinLengthString(expected int64, str *string) error

MinLengthString checks if the value of a string pointer has a length of at least 'expected'

func Validate

func Validate(i interface{}) error

Validate calls validate on structs that implement the Validateable interface. If they do not, then that struct is valid.

Types

type ErrorMap

type ErrorMap map[string]error

ErrorMap contains an entry for each invalid field in a struct. Values can be any struct that implements the go Error interface, including nested ErrorMaps.

func (ErrorMap) Error

func (em ErrorMap) Error() string

Error returns a JSON formatted representation of the ErrorMap.

type ErrorSlice

type ErrorSlice []error

ErrorSlice is a slice of errors. Typically an ErrorSlice will be an entry in the ErrorMap outputted by a generated Validate function, each element of the array represents a failed validation on that field.

func (ErrorSlice) Error

func (ea ErrorSlice) Error() string

Returns a JSON formatted representation of the ErrorSlice

type Validateable

type Validateable interface {
	Validate() error
}

Validateable specifies a generic error return type instead of an ErrorMap return type in order to allow for handwritten Validate methods to work in tandem with gokay generated Validate methods.

Jump to

Keyboard shortcuts

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