feat: game lobby service
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"galaxy/user/internal/domain/common"
|
||||
"galaxy/util"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
@@ -36,14 +37,29 @@ func ParseUserID(value string) (common.UserID, error) {
|
||||
return userID, nil
|
||||
}
|
||||
|
||||
// ParseRaceName trims value and validates it as one exact stored race name.
|
||||
func ParseRaceName(value string) (common.RaceName, error) {
|
||||
raceName := common.RaceName(NormalizeString(value))
|
||||
if err := raceName.Validate(); err != nil {
|
||||
// ParseUserName trims value and validates it as one exact stored user name.
|
||||
func ParseUserName(value string) (common.UserName, error) {
|
||||
userName := common.UserName(NormalizeString(value))
|
||||
if err := userName.Validate(); err != nil {
|
||||
return "", InvalidRequest(err.Error())
|
||||
}
|
||||
|
||||
return raceName, nil
|
||||
return userName, nil
|
||||
}
|
||||
|
||||
// ParseDisplayName trims value and validates it as one self-service display
|
||||
// name. An empty trimmed value is accepted and represents a reset to no
|
||||
// display name.
|
||||
func ParseDisplayName(value string) (common.DisplayName, error) {
|
||||
trimmed := NormalizeString(value)
|
||||
if trimmed == "" {
|
||||
return "", nil
|
||||
}
|
||||
if _, ok := util.ValidateTypeName(trimmed); !ok {
|
||||
return "", InvalidRequest(fmt.Sprintf("display_name %q is invalid", trimmed))
|
||||
}
|
||||
|
||||
return common.DisplayName(trimmed), nil
|
||||
}
|
||||
|
||||
// ParseReasonCode trims value and validates it as one machine-readable reason
|
||||
|
||||
Reference in New Issue
Block a user