mirror of
https://github.com/miniflux/v2.git
synced 2025-08-31 18:31:01 +00:00
feat(settings): add validation for entry order and categories sorting order
This commit is contained in:
parent
f15d29deb3
commit
5ae2cbd943
22 changed files with 77 additions and 16 deletions
|
@ -74,12 +74,24 @@ func ValidateUserModification(store *storage.Storage, userID int64, changes *mod
|
|||
}
|
||||
}
|
||||
|
||||
if changes.EntryOrder != nil {
|
||||
if err := ValidateEntryOrder(*changes.EntryOrder); err != nil {
|
||||
return locale.NewLocalizedError("error.invalid_entry_order")
|
||||
}
|
||||
}
|
||||
|
||||
if changes.EntriesPerPage != nil {
|
||||
if err := validateEntriesPerPage(*changes.EntriesPerPage); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if changes.CategoriesSortingOrder != nil {
|
||||
if err := validateCategoriesSortingOrder(*changes.CategoriesSortingOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if changes.DisplayMode != nil {
|
||||
if err := validateDisplayMode(*changes.DisplayMode); err != nil {
|
||||
return err
|
||||
|
@ -214,6 +226,13 @@ func validateEntriesPerPage(entriesPerPage int) *locale.LocalizedError {
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateCategoriesSortingOrder(order string) *locale.LocalizedError {
|
||||
if order != "alphabetical" && order != "unread_count" {
|
||||
return locale.NewLocalizedError("error.invalid_categories_sorting_order")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateDisplayMode(displayMode string) *locale.LocalizedError {
|
||||
if displayMode != "fullscreen" && displayMode != "standalone" && displayMode != "minimal-ui" && displayMode != "browser" {
|
||||
return locale.NewLocalizedError("error.invalid_display_mode")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue