1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Refactor category validation

This commit is contained in:
Frédéric Guillot 2021-01-03 22:28:04 -08:00 committed by fguillot
parent e45cc2d2aa
commit 4468ef1410
13 changed files with 122 additions and 212 deletions

View file

@ -6,9 +6,6 @@ package form // import "miniflux.app/ui/form"
import (
"net/http"
"miniflux.app/errors"
"miniflux.app/model"
)
// CategoryForm represents a feed form in the UI
@ -16,20 +13,6 @@ type CategoryForm struct {
Title string
}
// Validate makes sure the form values are valid.
func (c CategoryForm) Validate() error {
if c.Title == "" {
return errors.NewLocalizedError("error.title_required")
}
return nil
}
// Merge update the given category fields.
func (c CategoryForm) Merge(category *model.Category) *model.Category {
category.Title = c.Title
return category
}
// NewCategoryForm returns a new CategoryForm.
func NewCategoryForm(r *http.Request) *CategoryForm {
return &CategoryForm{