MCPcopy Create free account
hub / github.com/daodst/chat / validateApplicationServiceUsername

Function validateApplicationServiceUsername

clientapi/routing/register.go:301–314  ·  view source on GitHub ↗

validateApplicationServiceUsername returns an error response if the username is invalid for an application service

(username string)

Source from the content-addressed store, hash-verified

299
300// validateApplicationServiceUsername returns an error response if the username is invalid for an application service
301func validateApplicationServiceUsername(username string) *util.JSONResponse {
302 if len(username) > maxUsernameLength {
303 return &util.JSONResponse{
304 Code: http.StatusBadRequest,
305 JSON: jsonerror.BadJSON(fmt.Sprintf("'username' >%d characters", maxUsernameLength)),
306 }
307 } else if !validUsernameRegex.MatchString(username) {
308 return &util.JSONResponse{
309 Code: http.StatusBadRequest,
310 JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./='"),
311 }
312 }
313 return nil
314}
315
316// validatePassword returns an error response if the password is invalid
317func validatePassword(password string) *util.JSONResponse {

Callers 2

RegisterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected