How to set a minimum username length of 6 characters for all users except administrators and staff?

We need users on the client side to be unable to enter fewer than 6 characters when filling out a form. However, administrators should be able to enter fewer characters through the admin panel. Security concerns are not important here, as we can manually fix any issues if someone bypasses this check.

If you could advise where to look in terms of JavaScript, I will try to create a theme component out of this.

Just imagine how cool it would be: limiting users in characters without breaking the system. It’s so simple, why hasn’t it been done yet?