-
-
Notifications
You must be signed in to change notification settings - Fork 910
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
Add allow_nil
qualifier to validate_presence_of
#1097
Comments
Hey @cjmao, There is an existing issue for this in #683. We have not seen much of a need for this -- after all, usually when you are using |
Thanks @mcmire , I've read the comments under the issue and the PR you mentioned. Seems this is a duplicate issue, and my use case is mostly the same with those in the comments. Currently i'm having a model which has a Since this field is optional, I think it's best to convert (only) empty string to So in this case, it indeed needs to validate the presence of this attribute, but only when it is not |
@cjmao Okay, thanks for that. Well, like I said, if you want to start a new PR based on the one that exists that would be great, and we can slip it into the next release. |
@mcmire thanks for the advice! |
allow_nil
qualifier to validate_presence_of
allow_nil
qualifier to validate_presence_of
Just looking over old issues. I'm going to close this since we have a PR for this. |
Rails supports
validates :some_attribute, presence: { allow_nil: true }
on models, but currently thevalidate_presence_of
matcher doesn't have theallow_nil
qualifier.It will be much simpler to write specs with this added.
Please let me know if it is not added for some reasons.
The text was updated successfully, but these errors were encountered: