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
You can also use this format:
validates :foo, length: {minimum: 5, maximum: 5}, allow_blank: true
Or since your min and max are the same, the following will also work:
validates :foo, length: {is: 5}, allow_blank: true