zorchenhimer/MovieNight

Move name checking into MovieNight/common

Closed this issue · 4 comments

Move name checking logic into MovieNight/common so the front end can also validate name via the wasm module. This will allow the same checking on both sides and save the UI a trip via websockets and showing possible errors. Keep the validation in the server since messages can still be send directly from the js websocket.

Do you mean also checking for name collisions? I'm not sure that can be shared between the server and wasm client. Both have their own lists of names and would need different logic to check both.

That said, I've moved the syntax validation of the name with commit 49e997c.

So, with the changes to colors I am working on in #45 and what we talked about on discord, there is also a name check for not being colors. Then there is the range of 3-35. But I am closing this since the function as added to common.

func IsValidName(name string) bool {
	return 3 <= len(name) && len(name) <= 36 &&
		usernameRegex.MatchString(name) && !IsValidColor(name)
}

@zorchenhimer the answer is no on checking name collisions. The front end names are just for visual and should not be checked.