Move ParseBool to optional (#33979)

(cherry picked from commit 25b6f388651c893ecafce918f27bef7e4ae9a967)
This commit is contained in:
Lunny Xiao 2025-03-23 20:53:30 -07:00 committed by Gusted
parent 9018e5bc19
commit f68d49cb9e
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 31 additions and 33 deletions

View file

@ -14,22 +14,11 @@ import (
"strconv"
"strings"
"forgejo.org/modules/optional"
"golang.org/x/crypto/ssh"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// OptionalBoolParse get the corresponding optional.Option[bool] of a string using strconv.ParseBool
func OptionalBoolParse(s string) optional.Option[bool] {
v, e := strconv.ParseBool(s)
if e != nil {
return optional.None[bool]()
}
return optional.Some(v)
}
// IsEmptyString checks if the provided string is empty
func IsEmptyString(s string) bool {
return len(strings.TrimSpace(s)) == 0