Documentation ¶
Index ¶
- Variables
- func CompareISO8601Dates(older, recent string) (bool, error)
- func DecodeJSONStrict(readable io.Reader, i interface{}) error
- func ISO8601ShortDateToTime(date string, location ...*time.Location) (time.Time, error)
- func IsValidHostnamePort(hostport string) bool
- func ValidateJSONBody(jbody io.Reader, dest interface{}, drop ...bool) (validated []byte, err error)
- func ValidatorErrorMessage(err error) string
Constants ¶
This section is empty.
Variables ¶
var (
M = modifiers.New()
)
var V = validator.New()
Functions ¶
func CompareISO8601Dates ¶ added in v0.6.3
CompareISO8601Dates is a convenient method to compare that one ISO8601 date is older than the other.
func DecodeJSONStrict ¶
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
ISO8601ShortDateToTime converts a date like 2021-07-22 as a time.Time. Note that the resulting timezone is +00:00.
func IsValidHostnamePort ¶
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 ¶
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.