domain.*User.Validate   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
package domain
2
3
import (
4
	"github.com/go-playground/validator/v10"
5
	"gorm.io/gorm"
6
)
7
8
type User struct {
9
	gorm.Model `swaggerignore:"true"`
10
	Username   string `json:"username"`                             // Username of the user
11
	Email      string `json:"email" validate:"email" gorm:"unique"` // Email of the user
12
	Password   string `json:"-"`                                    // Password of the user
13
	Avatar     string `json:"avatar" validate:"avatar"`             // Avatar of the user
14
}
15
16
func (u *User) Validate() error {
17
	validate := validator.New()
18
	return validate.Struct(u)
19
}
20