From 521f081ba0555b4328299b69b3ab9e8654dd668a Mon Sep 17 00:00:00 2001 From: dhax Date: Mon, 30 Oct 2017 00:02:29 +0100 Subject: [PATCH] remove error check redundancy --- auth/handler.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/auth/handler.go b/auth/handler.go index 6bd4aba..5919eec 100644 --- a/auth/handler.go +++ b/auth/handler.go @@ -33,12 +33,9 @@ func (body *loginRequest) Bind(r *http.Request) error { body.Email = strings.TrimSpace(body.Email) body.Email = strings.ToLower(body.Email) - if err := validation.ValidateStruct(body, + return validation.ValidateStruct(body, validation.Field(&body.Email, validation.Required, is.Email), - ); err != nil { - return err - } - return nil + ) } func (rs *Resource) login(w http.ResponseWriter, r *http.Request) { @@ -91,12 +88,9 @@ type tokenResponse struct { func (body *tokenRequest) Bind(r *http.Request) error { body.Token = strings.TrimSpace(body.Token) - if err := validation.ValidateStruct(body, + return validation.ValidateStruct(body, validation.Field(&body.Token, validation.Required, is.Alphanumeric), - ); err != nil { - return err - } - return nil + ) } func (rs *Resource) token(w http.ResponseWriter, r *http.Request) {