package utils import ( "regexp" "relay-server/config" ) func IsValidUsername(username interface{}) bool { // Checks if username is type of string strUsername, ok := username.(string) if !ok { return false } match, _ := regexp.MatchString(config.USERNAME_REGEX, strUsername) if !match { return false } // Checks if username length is valid if len(strUsername) < config.MIN_USERNAME_LENGTH { return false } if len(strUsername) > config.MAX_USERNAME_LENGTH { return false } return true } func IsValidPassword(password interface{}) bool { strPassword, ok := password.(string) if !ok { return false } if len(strPassword) < config.MIN_PASSWORD_LENGTH { return false } if len(strPassword) > config.MAX_PASSWORD_LENGTH { return false } match, _ := regexp.MatchString(config.PASSWORD_REGEX, strPassword) if !match { return false } return true }