1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

fix(api): hide_globally categories field should be a boolean

This commit is contained in:
Frédéric Guillot 2025-04-21 18:45:30 -07:00
parent 764212f37c
commit ccc7bada90
16 changed files with 262 additions and 70 deletions

View file

@ -10,7 +10,7 @@ import (
)
// ValidateCategoryCreation validates category creation.
func ValidateCategoryCreation(store *storage.Storage, userID int64, request *model.CategoryRequest) *locale.LocalizedError {
func ValidateCategoryCreation(store *storage.Storage, userID int64, request *model.CategoryCreationRequest) *locale.LocalizedError {
if request.Title == "" {
return locale.NewLocalizedError("error.title_required")
}
@ -23,13 +23,15 @@ func ValidateCategoryCreation(store *storage.Storage, userID int64, request *mod
}
// ValidateCategoryModification validates category modification.
func ValidateCategoryModification(store *storage.Storage, userID, categoryID int64, request *model.CategoryRequest) *locale.LocalizedError {
if request.Title == "" {
return locale.NewLocalizedError("error.title_required")
}
func ValidateCategoryModification(store *storage.Storage, userID, categoryID int64, request *model.CategoryModificationRequest) *locale.LocalizedError {
if request.Title != nil {
if *request.Title == "" {
return locale.NewLocalizedError("error.title_required")
}
if store.AnotherCategoryExists(userID, categoryID, request.Title) {
return locale.NewLocalizedError("error.category_already_exists")
if store.AnotherCategoryExists(userID, categoryID, *request.Title) {
return locale.NewLocalizedError("error.category_already_exists")
}
}
return nil