diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 16:18:20 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 16:18:20 +0530 |
commit | 776522d8741752832981b17ec81deb11a298ef57 (patch) | |
tree | f7c0654f2b3dbc475c2a32daa5c623eec0ffce4a /customer/validators.go | |
parent | 95dfc551f7eaaf6e8ebdefce1b733951354ac40d (diff) |
different customers for different users
Diffstat (limited to 'customer/validators.go')
-rw-r--r-- | customer/validators.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/customer/validators.go b/customer/validators.go index 6c51ad9..bfd244f 100644 --- a/customer/validators.go +++ b/customer/validators.go @@ -26,11 +26,11 @@ import ( // NOTE: very inefficient and really really really dumb but it works // TODO: find a better (or even a remotely good) way -func validateContactField(field, value string) error { +func validateContactField(field, value string, userId uint) error { if value != "" { var count int64 err := db.Model(&CustomerContact{}). - Where(field + " = ?", value). + Where(field + " = ? and user_id = ?", value, userId). Count(&count). Error @@ -64,7 +64,7 @@ func (c *CustomerContact) validate() error { var err error for _, i := range [][]string{{"phone", c.Phone}, {"email", c.Email}, {"website", c.Website}} { - err = validateContactField(i[0], i[1]) + err = validateContactField(i[0], i[1], c.UserID) if err != nil { return err } @@ -90,7 +90,7 @@ func (c *Customer) validate() error { var count int64 err := db.Model(&Customer{}). Select("gstin"). - Where("gstin = ?", c.Gstin). + Where("gstin = ? and user_id = ?", c.Gstin, c.UserID). Count(&count). Error |