craban/model/user.go

34 lines
477 B
Go
Raw Normal View History

2021-09-11 19:50:34 +01:00
package model
import (
"fmt"
)
2021-09-11 19:50:34 +01:00
type User struct {
ID int
Name string
Mail string
Username string
Password string
}
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
}