I have a field that I would like to validate. I want the field to be able to be left blank, but if a user is entering data I want it to be in a certain format. Currently I am us
Or even more concise (with the new hash syntax), from the validates documentation:
validates :foo, length: 5..5, allow_blank: true
The upper limit should probably represent somehting more meaningful like "in: 5..20", but just answering the question to the letter.