Trim category name before validation.

Fixes #1379