adding proper null check for usernameValidation js method