codegram / date_validator

A simple, ORM agnostic, Ruby >=2.2 compatible date validator for Rails, based on ActiveModel.
http://thoughts.codegram.com/date-validation-with-rails-3
MIT License
496 stars 82 forks source link

Fails on :allow_blank => true #22

Closed konung closed 12 years ago

konung commented 12 years ago

Hello.

I was trying to use gem to do some validation, and ran into a problem:

trying to do validation like so:

validates :delivery_date, :allow_blank => true, :date => {:after => Date.today, :before => Date.today + 30.days }

I keep getting "invalid date" error if the attribute is blank ( which it should allow for if the user didn't specify anything )

Am I doing something wrong?

konung commented 12 years ago

hmm, it seems it was failing, cause delivery_date is a virtual attribute in my model.