mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Refactor HTTP Client and LocalizedError packages
This commit is contained in:
parent
120aabfbce
commit
14e25ab9fe
104 changed files with 1277 additions and 10672 deletions
|
@ -4,31 +4,32 @@
|
|||
package validator // import "miniflux.app/v2/internal/validator"
|
||||
|
||||
import (
|
||||
"miniflux.app/v2/internal/locale"
|
||||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/storage"
|
||||
)
|
||||
|
||||
// ValidateCategoryCreation validates category creation.
|
||||
func ValidateCategoryCreation(store *storage.Storage, userID int64, request *model.CategoryRequest) *ValidationError {
|
||||
func ValidateCategoryCreation(store *storage.Storage, userID int64, request *model.CategoryRequest) *locale.LocalizedError {
|
||||
if request.Title == "" {
|
||||
return NewValidationError("error.title_required")
|
||||
return locale.NewLocalizedError("error.title_required")
|
||||
}
|
||||
|
||||
if store.CategoryTitleExists(userID, request.Title) {
|
||||
return NewValidationError("error.category_already_exists")
|
||||
return locale.NewLocalizedError("error.category_already_exists")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateCategoryModification validates category modification.
|
||||
func ValidateCategoryModification(store *storage.Storage, userID, categoryID int64, request *model.CategoryRequest) *ValidationError {
|
||||
func ValidateCategoryModification(store *storage.Storage, userID, categoryID int64, request *model.CategoryRequest) *locale.LocalizedError {
|
||||
if request.Title == "" {
|
||||
return NewValidationError("error.title_required")
|
||||
return locale.NewLocalizedError("error.title_required")
|
||||
}
|
||||
|
||||
if store.AnotherCategoryExists(userID, categoryID, request.Title) {
|
||||
return NewValidationError("error.category_already_exists")
|
||||
return locale.NewLocalizedError("error.category_already_exists")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue