Announcement Announcement Module
Collapse
No announcement yet.
Rules: check multiple properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rules: check multiple properties

    hi,

    a user should provide his first and lastName and also one of following idCode OR his accessKey AND a location.
    so i have
    required("lastName")
    required("firstName")
    or(required("idCode"),and(required("accessKey"),re quired("location"))
    but how do i do this in code?
    Code:
    public class MyRule extends Rules {
    
    	
    	protected void initRules() {
    		add(required("lastName"));
    		add(required("firstName"));
    ...
    thx,

    DD

  • #2
    RequiredIfTrue

    I used PropertyPresent & RequiredIfTrue to solve my problem...

    Code:
    ....
          private PropertyPresent id_present = new PropertyPresent("idCode");
          private PropertyPresent loc_present = new PropertyPresent("location");
    
          protected void initRules() {
              add(required("lastName"));
              add(required("firstName"));
              add(new RequiredIfTrue("accessKey",not(id_present)));
              add(new RequiredIfTrue("idCode",loc_present));
    ...
    DD

    Comment

    Working...
    X