mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-26 17:13:32 -06:00
start adding page validation
This commit is contained in:
parent
e96bf44497
commit
4e80d0bf79
5 changed files with 80 additions and 84 deletions
31
internal/id/page.go
Normal file
31
internal/id/page.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package id
|
||||
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/paging"
|
||||
)
|
||||
|
||||
// ValidatePage ...
|
||||
func ValidatePage(page *paging.Page) {
|
||||
if page == nil {
|
||||
// unpaged
|
||||
return
|
||||
}
|
||||
|
||||
switch page.Order() {
|
||||
// If the page order is ascending,
|
||||
// ensure that a minimum value is set.
|
||||
// This will be used as the cursor.
|
||||
case paging.OrderAscending:
|
||||
if page.Min.Value == "" {
|
||||
page.Min.Value = Lowest
|
||||
}
|
||||
|
||||
// If the page order is descending,
|
||||
// ensure that a maximum value is set.
|
||||
// This will be used as the cursor.
|
||||
case paging.OrderDescending:
|
||||
if page.Max.Value == "" {
|
||||
page.Max.Value = Highest
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue