From 2dc0f02d1cf18bcbf0df826ad73f7e5002fff67f Mon Sep 17 00:00:00 2001 From: dhax Date: Fri, 13 Oct 2017 01:01:31 +0200 Subject: [PATCH] remove redundancy in models BeforeInsert hook --- auth/account.go | 5 +---- models/profile.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/auth/account.go b/auth/account.go index ac4cc4c..6c68ec5 100644 --- a/auth/account.go +++ b/auth/account.go @@ -33,10 +33,7 @@ func (a *Account) BeforeInsert(db orm.DB) error { a.CreatedAt = now a.UpdatedAt = now } - if err := a.Validate(); err != nil { - return err - } - return nil + return a.Validate() } // BeforeUpdate hook executed before database update operation. diff --git a/models/profile.go b/models/profile.go index 9d4dc22..115b6ef 100644 --- a/models/profile.go +++ b/models/profile.go @@ -25,11 +25,8 @@ func (p *Profile) BeforeInsert(db orm.DB) error { // BeforeUpdate hook executed before database update operation. func (p *Profile) BeforeUpdate(db orm.DB) error { - if err := p.Validate(); err != nil { - return err - } p.UpdatedAt = time.Now() - return nil + return p.Validate() } // Validate validates Profile struct and returns validation errors.