-
Notifications
You must be signed in to change notification settings - Fork 67
Validate with conditions #128
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
base: master
Are you sure you want to change the base?
Conversation
The `:if` options allows to define conditions for validations to be executed just in concrete contexts.
|
This is really great. Also parallels the way Rails can handle validations. Here are a couple of requests:
By the way, this is failing in Travis. Sometimes Travis needs a refresh to pass. Thanks again! |
|
Oops! sorry for the failing tests, they go green locally 😓. And agree with you! would be better to get it working with But I'm not sure about how could I access the model attributes implicitly from inside the block. Do you know what I mean? Do you know how can I do it? My use case by the moments works well with what is done in this PR: |
|
It looks like you are doing a send for the Note that the validator is an instance method of the model, so you would be able to write code like this: What do you think? Would something like this work? |
|
You are right, it should work. Let me check it out and I'll come back with some changes 😉 Right? Thx! |
|
I just used Something like that. It's just one other way to write validating code -- moving the method up to the |
|
Yes, totally agree. |
|
Sorry @sxross, I was thinking on it and I'm not "totally agree" with you.
And I think that two scopes for the same option is not correct. What do you think? |
d5cedb3 to
5f9d47b
Compare
|
@sxross Travis is failing again. I don't understand why, all is working fine in my machine. Thx! |
|
I agree. That makes perfect sense.
|
|
Please try removing |
5879b0e to
aa45ed7
Compare
aa45ed7 to
20b82cb
Compare
|
@sxross I've made it working doing some changes in Travis configuration and gem dependencies. |
I just want to set starting point with conditional validations.
I think it'd be cool to provide some feature to execute validations just in some defined contexts.
In this PR I'm adding the
:ifoption as a very silly way to provide this.