// Create a new constraintrule, supply constraint type, and field that this rule
// applies to.
ConstraintRule cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.userName");
// Set the constraints
cr.setValidRange(new Range(2, 60) );
cr.unique=true; // public variabel will be changed to setter later
cr.required=true; // public variabel will be changed to setter later
cr.setValue(userName);
// Add this rule to the rulelist
rules.addRule(cr);
// Set the rest of the rules
cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.password");
cr.setValidRange(new Range(4, 15));
cr.required = true;
cr.setValue(password);
rules.addRule(cr);
cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.firstName");
cr.setValidRange(new Range(1, 30));
cr.required = true;
cr.setValue(firstName);
rules.addRule(cr);
cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.lastName");
cr.setValidRange(new Range(1, 30));
cr.required = true;
cr.setValue(lastName);
rules.addRule(cr);
cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.EMAIL, "SystemUser.email");
cr.setValidRange(new Range(50));
cr.required = true;
cr.setValue(email);
rules.addRule(cr);
}