validateApplicationServiceUsername returns an error response if the username is invalid for an application service
(username string)
| 299 | |
| 300 | // validateApplicationServiceUsername returns an error response if the username is invalid for an application service |
| 301 | func 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 |
| 317 | func validatePassword(password string) *util.JSONResponse { |
no outgoing calls
no test coverage detected