diff --git a/context.go b/context.go index 1ed65fed..50150e6f 100644 --- a/context.go +++ b/context.go @@ -469,11 +469,11 @@ func (c *Context) BindQuery(obj interface{}) error { } // MustBindWith binds the passed struct pointer using the specified binding engine. -// It will abort the request with HTTP 400 if any error ocurrs. +// It will abort the request with HTTP 422(Unprocessable Entity) if any error ocurrs. // See the binding package. func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) { if err = c.ShouldBindWith(obj, b); err != nil { - c.AbortWithError(400, err).SetType(ErrorTypeBind) + c.AbortWithError(422, err).SetType(ErrorTypeBind) } return diff --git a/context_test.go b/context_test.go index 8cd05f6c..821c5870 100644 --- a/context_test.go +++ b/context_test.go @@ -1224,7 +1224,7 @@ func TestContextBadAutoBind(t *testing.T) { assert.Empty(t, obj.Bar) assert.Empty(t, obj.Foo) - assert.Equal(t, w.Code, 400) + assert.Equal(t, w.Code, 422) assert.True(t, c.IsAborted()) }