You can find the username validation function in this file: ow_system_plugins/base/controllers/join.php
But, we strongly do not recommend to allow spaces in the usernames since the usernames are used in the URLs and the space may cause the problems with the software routing system, thus, lead to negative consequences.