aboutsummaryrefslogtreecommitdiff
path: root/customer/validators.go
diff options
context:
space:
mode:
Diffstat (limited to 'customer/validators.go')
-rw-r--r--customer/validators.go8
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