Skip to main content

Bug Tracker

Side navigation

#2456 closed feature (fixed)

Opened March 04, 2008 08:07PM UTC

Closed March 12, 2008 05:03PM UTC

[validate] Accept dependency expression for every method

Reported by: joern Owned by: joern
Priority: major Milestone:
Component: plugin Version:
Keywords: Cc:
Blocked by: Blocking:
Description

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.

Attachments (0)
Change History (4)

Changed March 04, 2008 08:14PM UTC by joern comment:1

description: 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, let it be, if it doesn't, convert the parameter into a {param: parameter, depends:true} object.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.

Changed March 04, 2008 10:51PM UTC by joern comment:2

resolution: → fixed
status: newclosed

Fixed in [4862]. Thanks Dan!

Changed March 05, 2008 02:49PM UTC by scott.gonzal comment:3

resolution: fixed
status: closedreopened

Jörn closed the wrong ticket...

Changed March 12, 2008 05:03PM UTC by scott.gonzal comment:4

resolution: → fixed
status: reopenedclosed

Fixed in [4872] and [4889].