Ticket #2456 (closed feature: fixed)
[validate] Accept dependency expression for every method
| Reported by: | joern | Owned by: | joern |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | plugin | Version: | |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by joern) (diff)
Usage:
billingAddress: {
required:true,
minlength:5
equalTo: {
param: "#shippingaddress",
depends: "#compare:checked"
}
}
Here the billing address must be the same as the shipping addres, but only if some checkbox #compare is checked.
Every method'd accept that {depends:expression} object as the parameter, skipping the method if it doesn't match. The expression is the same as what required accepts, but doesn't kill the chain as required does. Even required can accept the depends parameter.
Implementation: Extend normalizeRule to check for the parameter. If it has a depends-property, evaluate it. If it returns true, return a normal {name:param} rule. If not, drop the rule. Return normal rule if no param specified or no depends-property.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
