-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Passing :allow_blank option raises #243
Comments
Hi @joelmoss |
I am pushing a quick MR to make the message clearer for future users |
…ption-raises [Validator] Better error message when using :allow_blank/nil with attached validator (#243)
👋 here, and thanks for the gem. I'm also wondering about allowing optional attachement and I went to this issue. But it's not very easy to read and guess for other developpers: for example with this line: Instead of adding a comment in our code everywhere optional attachements are validated, Or should I go to thanks in advance for your answer, if you want I can open a tiny PR on ready to highlight this usecase. |
Hi from Lyon @Polo2 👋 We could develop something like ActiveStorage You could write your association with one of these to make you code more explicit. All the gem validators, expect the I think it's by far the simplest & clearer option, but I am open to discussion :) |
I got hit by this today after I upgraded to newer version of this gem. This was my code before:
How should this be modified with the newer version? Should I just drop |
Hi @amit! |
Thanks! So the new code then should be:
Correct? This allows no attachment as valid, but if it is attached, then it needs to comply with the content_type given? The documentation of |
@amit that's exactly it! Your code does what you explained. |
I am trying to allow a blank attachment during validation...
But it fails with...
ArgumentError: You cannot pass the :allow_blank option to this validator (ArgumentError)
I can see in the code that the
allow_blank
option is supported, so why does this not work?thankyou
The text was updated successfully, but these errors were encountered: