Optie om gebruikersnaam niet te laten beginnen of eindigen met alfanumerieke tekens

I’ve once spoken with someone about ruby. Is this doable with a plugin? I heard him mention I can override functions, such as in this case the validator. Is this correct?