-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't test the validation with allow_blank: true #140
Comments
Do you have the plugin parser enabled in the initializer? |
I didn't have it but I do have now and the spec above still don't want to pass. If it will help or if it will turn out as a new issue:
|
Using
Allow blank values, any string values become allowed. I tried enabling plugin parser, but it did not resolve this issue. also, enabling |
According to one of the answers here the problem is that recent versions of Rails do a type cast on values before validation is called and that changes the stored value to The gem needs to detect a case where:
and treat it as an invalid datetime having been entered. Or just validate against |
Also, fwiw, it's probably preferable to use |
Hi! I have the Order model with :completed_date attribute. And I would like to validate :completed_date in the following way
But my spec for this validation doesn't work
I believe it's because any incorrect date value sets to nil and nil is valid value since I have
allow_blank: true
in my validationWhen I remove
allow_blank: true
from my validation, the spec above works perfectly but I really need to permit blank :completed_date for my orders.So I wonder if I do something wrong or if there is any way to test such validation?
P.S. I have tried all of the following constructions and all of them didn't work
validates_date :completed_date, allow_blank: true
validates :completed_date, timeliness: { type: :date }, allow_blank: true
validates :completed_date, timeliness: { type: :date, allow_blank: true }
The text was updated successfully, but these errors were encountered: