You could accomplish this a few ways.
The simplest way to do so would be to create a formula field that utilizes the
This function will remove any trailing whitespace in text strings.
The next step-up in complexity would be an automation.
Depending on how many automation runs you have, you can set the trigger however you’d want.
For the action, you’d want to take the value(s) in the text field and have the update action utilize the trim text transformation to append the value into the field.
The cleanest, but most complex method I can come up with is to utilize a script automation.
String.trim method would knock this out easily.
Then you can just append the validated data to the field.
If people will be typing directly in the field, I don’t recommend using an automation. The automation might trigger while the person is typing.
However, if the values will come in complete via a form submission or the API, you can have an automation that removes trailing spaces. You don’t even need to have a formula field in some cases. Have an “On Form Submission” trigger. Then update the record with the trimmed field name. In the “Update Record” action, when you select a field value, instead of directly inserting the field value, click “continue” and pick the “trim” option.