MCPcopy Create free account
hub / github.com/gotify/server / validationErrorToText

Function validationErrorToText

error/handler.go:43–56  ·  view source on GitHub ↗
(e validator.FieldError)

Source from the content-addressed store, hash-verified

41}
42
43func validationErrorToText(e validator.FieldError) string {
44 runes := []rune(e.Field())
45 runes[0] = unicode.ToLower(runes[0])
46 fieldName := string(runes)
47 switch e.Tag() {
48 case "required":
49 return fmt.Sprintf("Field '%s' is required", fieldName)
50 case "max":
51 return fmt.Sprintf("Field '%s' must be less or equal to %s", fieldName, e.Param())
52 case "min":
53 return fmt.Sprintf("Field '%s' must be more or equal to %s", fieldName, e.Param())
54 }
55 return fmt.Sprintf("Field '%s' is not valid", fieldName)
56}
57
58func writeError(ctx *gin.Context, errString string) {
59 status := http.StatusBadRequest

Callers 1

HandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…