|
@@ -4,6 +4,7 @@
|
|
|
package validator // import "miniflux.app/v2/internal/validator"
|
|
package validator // import "miniflux.app/v2/internal/validator"
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
|
|
|
"miniflux.app/v2/internal/model"
|
|
"miniflux.app/v2/internal/model"
|
|
@@ -12,7 +13,7 @@ import (
|
|
|
// ValidateEntriesStatusUpdateRequest validates a status update for a list of entries.
|
|
// ValidateEntriesStatusUpdateRequest validates a status update for a list of entries.
|
|
|
func ValidateEntriesStatusUpdateRequest(request *model.EntriesStatusUpdateRequest) error {
|
|
func ValidateEntriesStatusUpdateRequest(request *model.EntriesStatusUpdateRequest) error {
|
|
|
if len(request.EntryIDs) == 0 {
|
|
if len(request.EntryIDs) == 0 {
|
|
|
- return fmt.Errorf(`the list of entries cannot be empty`)
|
|
|
|
|
|
|
+ return errors.New(`the list of entries cannot be empty`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return ValidateEntryStatus(request.Status)
|
|
return ValidateEntryStatus(request.Status)
|
|
@@ -35,17 +36,17 @@ func ValidateEntryOrder(order string) error {
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return fmt.Errorf(`invalid entry order, valid order values are: "id", "status", "changed_at", "published_at", "created_at", "category_title", "category_id", "title", "author"`)
|
|
|
|
|
|
|
+ return errors.New(`invalid entry order, valid order values are: "id", "status", "changed_at", "published_at", "created_at", "category_title", "category_id", "title", "author"`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ValidateEntryModification makes sure the entry modification is valid.
|
|
// ValidateEntryModification makes sure the entry modification is valid.
|
|
|
func ValidateEntryModification(request *model.EntryUpdateRequest) error {
|
|
func ValidateEntryModification(request *model.EntryUpdateRequest) error {
|
|
|
if request.Title != nil && *request.Title == "" {
|
|
if request.Title != nil && *request.Title == "" {
|
|
|
- return fmt.Errorf(`the entry title cannot be empty`)
|
|
|
|
|
|
|
+ return errors.New(`the entry title cannot be empty`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if request.Content != nil && *request.Content == "" {
|
|
if request.Content != nil && *request.Content == "" {
|
|
|
- return fmt.Errorf(`the entry content cannot be empty`)
|
|
|
|
|
|
|
+ return errors.New(`the entry content cannot be empty`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
return nil
|