bcardarella/client_side_validations — Issue #200: forced conditionals
Author: taavo
Created: 2011-10-13 19:39:02+00:00
State: open

(This is a dup of the closed #163, and comment copypasta from [here](https://github.com/bcardarella/client_side_validations/issues/163#issuecomment-2327337), because I'm not sure if comments on old closed issues get noticed.)

So... forced conditionals. My understanding, based on [this](https://github.com/bcardarella/client_side_validations/issues/81) and [this](https://github.com/bcardarella/client_side_validations/issues/133#issuecomment-1857986) 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](https://github.com/bcardarella/client_side_validations/blob/master/test/action_view/cases/test_helpers.rb#L427) and [here](https://github.com/bcardarella/client_side_validations/blob/master/test/action_view/cases/test_helpers.rb#L496), 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] (https://github.com/bcardarella/client_side_validations/blob/master/lib/client_side_validations/action_view/form_builder.rb#L96) 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.