I'm trying to find a way to reject creation of a message if the form filled out is empty (including spaces and new lines). Currently I have the form set to required: true
but that doesn't stop a user from hitting the spacebar and sending the message. I don't know if Rails has a built in validation or if there is some regex I would have to use.
Asked
Active
Viewed 325 times
-1

Antonio
- 731
- 7
- 28
-
Maybe [this thread](http://stackoverflow.com/questions/15482354/how-to-validate-text-isnt-blank-in-rails) can help. – Wiktor Stribiżew Feb 16 '17 at 20:03
1 Answers
0
You're after a presence
validator in your model. It will explicitly require that your field's present?
be true, which it won't be if the column contains only whitespace.

user229044
- 232,980
- 40
- 330
- 338