How to trim leading/trailing whitespace?

When creating a new user through the Web UI of UCS by copy-pasting the given and family names it can happen that the copy-paste also captures whitespace around the names. We would like to prevent this.

Is there a mechanism in UCS that can help us with trimming undesired leading or trailing whitespaces, e.g. in user names?

Thanks!