diff --git a/backend/src/services/category.go b/backend/src/services/category.go index 7206c221c..738a49c47 100644 --- a/backend/src/services/category.go +++ b/backend/src/services/category.go @@ -3,7 +3,6 @@ package services import ( "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" - "github.com/GenerateNU/sac/backend/src/utilities" "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" @@ -22,7 +21,7 @@ type CategoryService struct { } func (c *CategoryService) CreateCategory(category models.Category) (*models.Category, error) { - if err := utilities.ValidateData(category); err != nil { + if err := c.Validate.Struct(category); err != nil { return nil, fiber.NewError(fiber.StatusBadRequest, "failed to validate the data") } diff --git a/backend/src/services/tag.go b/backend/src/services/tag.go index 26106981a..a56f26a36 100644 --- a/backend/src/services/tag.go +++ b/backend/src/services/tag.go @@ -27,7 +27,7 @@ func (t *TagService) CreateTag(tagBody models.CreateTagRequestBody) (*models.Tag CategoryID: tagBody.CategoryID, } - if err := utilities.ValidateData(tag); err != nil { + if err := t.Validate.Struct(tag); err != nil { return nil, fiber.NewError(fiber.StatusBadRequest, "failed to validate the data") } @@ -56,7 +56,7 @@ func (t *TagService) UpdateTag(id string, tagBody models.UpdateTagRequestBody) ( CategoryID: tagBody.CategoryID, } - if err := utilities.ValidateData(tag); err != nil { + if err := t.Validate.Struct(tag); err != nil { return nil, fiber.NewError(fiber.StatusBadRequest, "failed to validate the data") }