2021-11-08 04:53:03 +00:00
|
|
|
package usermngmt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/Selly-Modules/logger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (co CreateOptions) validate() error {
|
|
|
|
// Name
|
|
|
|
if co.Name == "" {
|
|
|
|
logger.Error("usermngmt - Create: no Name data", logger.LogData{
|
|
|
|
"payload": co,
|
|
|
|
})
|
|
|
|
return errors.New("no name data")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Phone
|
|
|
|
if co.Phone == "" {
|
|
|
|
logger.Error("usermngmt - Create: no phone data", logger.LogData{
|
|
|
|
"payload": co,
|
|
|
|
})
|
|
|
|
return errors.New("no phone data")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Email
|
|
|
|
if co.Email == "" {
|
|
|
|
logger.Error("usermngmt - Create: no email data", logger.LogData{
|
|
|
|
"payload": co,
|
|
|
|
})
|
|
|
|
return errors.New("no email data")
|
|
|
|
}
|
|
|
|
|
2021-11-08 08:34:20 +00:00
|
|
|
// HashedPassword
|
|
|
|
if co.HashedPassword == "" {
|
|
|
|
logger.Error("usermngmt - Create: no hashedPassword data", logger.LogData{
|
2021-11-08 04:53:03 +00:00
|
|
|
"payload": co,
|
|
|
|
})
|
2021-11-08 08:34:20 +00:00
|
|
|
return errors.New("no hashedPassword data")
|
2021-11-08 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Status
|
|
|
|
if co.Status == "" {
|
|
|
|
logger.Error("usermngmt - Create: no status data", logger.LogData{
|
|
|
|
"payload": co,
|
|
|
|
})
|
|
|
|
return errors.New("no status data")
|
|
|
|
}
|
|
|
|
|
|
|
|
// RoleID
|
2021-11-08 08:34:20 +00:00
|
|
|
if co.RoleID.IsZero() {
|
|
|
|
logger.Error("usermngmt - Create: invalid roleID data", logger.LogData{
|
2021-11-08 04:53:03 +00:00
|
|
|
"payload": co,
|
|
|
|
})
|
2021-11-08 08:34:20 +00:00
|
|
|
return errors.New("invalid roleID data")
|
2021-11-08 04:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|