Handle whitespace consistently
Text with leading or trailing whitespace is treated inconsistently:
- Nicknames: whitespace isn't trimmed, whitespace-only names are allowed
- Private messages: whitespace is trimmed, whitespace-only messages are allowed but become empty after trimming
- Forum names: whitespace isn't trimmed, whitespace-only names are allowed
- Forum invitations: whitespace isn't trimmed, whitespace-only messages are allowed
- Forum posts: whitespace is trimmed, whitespace-only posts aren't allowed
- Private group names: whitespace isn't trimmed, whitespace-only names are allowed
- Private group invitations: whitespace isn't trimmed, whitespace-only messages are allowed
- Private group posts: whitespace is trimmed, whitespace-only posts aren't allowed
- Blog posts: whitespace is trimmed, whitespace-only posts are allowed but become empty after trimming
- Blog comments: whitespace isn't trimmed, whitespace-only comments are allowed
Let's do the following everywhere:
When entering text:
- Trim leading and trailing whitespace
- If the trimmed text is empty and the input is optional (for example a blog comment), pass null to the backend
- If the trimmed text is empty and the input isn't optional (for example a blog post), don't accept the input
- If the trimmed text is too long, don't accept the input
- If the trimmed text isn't empty or too long, pass it to the backend
When validating messages (including author names and group names):
- Reject null if the text isn't optional
- Reject the text if it's empty or too long
- Reject the text if it has leading or trailing whitespace