validation

package
Version: v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	M = modifiers.New()
)

Functions

func CompareISO8601Dates added in v0.6.3

func CompareISO8601Dates(older, recent string) (bool, error)

CompareISO8601Dates is a convenient method to compare that one ISO8601 date is older than the other.

func DecodeJSONStrict

func DecodeJSONStrict(readable io.Reader, i interface{}) error

DecodeJSONStrict decodes into the given `i` while making sure not to allow extra fields that are not present in the struct for a strict decoding.

func ISO8601ShortDateToTime added in v0.9.0

func ISO8601ShortDateToTime(date string, location ...*time.Location) (time.Time, error)

ISO8601ShortDateToTime converts a date like 2021-07-22 as a time.Time. Note that the resulting timezone is +00:00.

func IsValidHostnamePort

func IsValidHostnamePort(hostport string) bool

IsValidHostnamePort returns true if the given hostport is a valid host:port

func ValidateJSONBody added in v0.3.4

func ValidateJSONBody(jbody io.Reader, dest interface{}, drop ...bool) (validated []byte, err error)

ValidateJSONBody parses the given JSON from the request, unmarshalls it into the given `dest`. If drop != false, the JSON is recreated based on the struct `dest` and returned as `validated`.

func ValidatorErrorMessage

func ValidatorErrorMessage(err error) string

ValidatorErrorMessage returns the first error message after validation; if it's not an instance of ValidationErrors then it will just return the normal .Error().

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL