All checks were successful
continuous-integration/drone/push Build is passing
29 lines
481 B
Go
29 lines
481 B
Go
package domain
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
ErrUnsupportedSortDirection = errors.New("unsupported sort direction")
|
|
)
|
|
|
|
type SortDirection uint8
|
|
|
|
const (
|
|
SortDirectionASC SortDirection = iota
|
|
SortDirectionDESC
|
|
)
|
|
|
|
func newSortDirection(s string) (SortDirection, error) {
|
|
switch strings.ToUpper(s) {
|
|
case "ASC":
|
|
return SortDirectionASC, nil
|
|
case "DESC":
|
|
return SortDirectionDESC, nil
|
|
}
|
|
return 0, fmt.Errorf("%w: \"%s\"", ErrUnsupportedSortDirection, s)
|
|
}
|