2021-09-11 19:50:34 +01:00
|
|
|
package model
|
|
|
|
|
2021-09-11 20:38:38 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2021-09-11 19:50:34 +01:00
|
|
|
type User struct {
|
2021-09-13 11:46:43 +01:00
|
|
|
ID int `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Mail string `json:"mail"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"-"`
|
2021-09-13 13:52:00 +01:00
|
|
|
Admin bool `json:"admin"`
|
2021-09-11 19:50:34 +01:00
|
|
|
}
|
2021-09-11 20:38:38 +01:00
|
|
|
|
|
|
|
func (u *User) IsValid() error {
|
|
|
|
if u.Name == "" {
|
|
|
|
return fmt.Errorf("name must not be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
if u.Mail == "" {
|
|
|
|
return fmt.Errorf("mail must not be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
if u.Username == "" {
|
|
|
|
return fmt.Errorf("username must not be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
if u.Password == "" {
|
|
|
|
return fmt.Errorf("password must not be empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|