context#ErrEmptyForm

Former-commit-id: c623e7ac433f11c9d89376bee0cd100aa26f35c5
This commit is contained in:
Gerasimos (Makis) Maropoulos 2018-10-03 20:49:49 +03:00
parent 120b5fb635
commit 0f2c5da7df

View File

@ -2289,6 +2289,9 @@ var (
errReadBody = errors.New("while trying to read %s from the request body. Trace %s") errReadBody = errors.New("while trying to read %s from the request body. Trace %s")
) )
// ErrEmptyForm will be thrown from `context#ReadForm` when empty request data.
var ErrEmptyForm = errors.New("form data: empty")
// ReadForm binds the formObject with the form data // ReadForm binds the formObject with the form data
// it supports any kind of struct. // it supports any kind of struct.
// //
@ -2296,7 +2299,7 @@ var (
func (ctx *context) ReadForm(formObject interface{}) error { func (ctx *context) ReadForm(formObject interface{}) error {
values := ctx.FormValues() values := ctx.FormValues()
if values == nil { if values == nil {
return errors.New("An empty form passed on ReadForm") return ErrEmptyForm
} }
// or dec := formbinder.NewDecoder(&formbinder.DecoderOptions{TagName: "form"}) // or dec := formbinder.NewDecoder(&formbinder.DecoderOptions{TagName: "form"})