Skip to content

Commit 56435d7

Browse files
committed
chore: use global validator object
1 parent 4132e77 commit 56435d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/infra/http/request/student.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"github.com/go-playground/validator/v10"
77
)
88

9+
// nolint: gochecknoglobals
10+
var validate = validator.New(validator.WithRequiredStructEnabled())
11+
912
type StudentCreate struct {
1013
Name string `json:"name,omitempty" validate:"required,alphaunicode"`
1114
Family string `json:"family,omitempty" validate:"required,alphaunicode"`
1215
}
1316

1417
func (sc StudentCreate) Validate() error {
15-
validate := validator.New(validator.WithRequiredStructEnabled())
16-
1718
if err := validate.Struct(sc); err != nil {
1819
return fmt.Errorf("create request validation failed %w", err)
1920
}

0 commit comments

Comments
 (0)