(FR #1090) trim inputs before validation

TODO: kill lots of repeated code

Change-Id: I768f014a8fb2a46952e0be91b3b974dc2def6a05
Merge "(FR #1090) trim inputs before validation"