package model

import (
	"fmt"
)

type User struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Mail     string `json:"mail"`
	Username string `json:"username"`
	Password string `json:"-"`
	Admin    bool   `json:"admin"`
}

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
}
