client_side_validations icon indicating copy to clipboard operation
client_side_validations copied to clipboard

forced conditionals

Open taavo opened this issue 15 years ago • 5 comments

(This is a dup of the closed #163, and comment copypasta from here, because I'm not sure if comments on old closed issues get noticed.)

So... forced conditionals. My understanding, based on this and this as well as other posts, is that if a field is manually marked with :validate => true, that field should get validated regardless of whether or not the validator has a conditional on it, and whether or not that conditional passes.

You've got tests for this here and here, and they pass, but both of them seem to be testing "incorrect" behavior. They make sure that if you don't meet the condition, the fields don't get validated, which is to say that nothing is getting "forced". Right?

The behavior can be flipped by changing this line like this:

- elsif force_validator_despite_conditional?(validator, filters) && !can_run_validator?(validator, method)
+ elsif !force_validator_despite_conditional?(validator, filters) && !can_run_validator?(validator, method)

I'm definitely very confused. Translating the above line into english I get: "If they trying to force the validator despite having a conditional, and the conditional fails, delete the conditional"? Lil help?

If my interpretation is correct, I can put together a push request with fixed tests shortly. Thanks.

taavo avatar Oct 13 '11 19:10 taavo

That whole section of code is very ugly and ripe for a refactor

bcardarella avatar Oct 13 '11 19:10 bcardarella

Running into this issue. The conditional fails which prevents validator information to be stored in the dom and when I check some box I want to dynamically reenable validation but the information isn't there. +1 for Pull Request #201

kirel avatar Dec 06 '11 13:12 kirel

+1 to this issue.

While the whole section could use a good simplification, I think you should fix this clear logic error in the meantime. It's pretty fundamental to how client_side_validations is meant to work.

robertdapice avatar May 17 '12 02:05 robertdapice

+1 from me too.

I hit this stumbling block within an hour of starting to use client_side_validations. Is there a workaround that doesn't involve updating the DOM myself and injecting the validator objects client-side?

woodyza avatar Jul 13 '12 11:07 woodyza

The forced conditional code has been completely re-written. It has been moved entirely into the model where it should be instead of the view. I'm closing this issue. If people have any future problems please open a new issue.

bcardarella avatar Oct 02 '12 04:10 bcardarella