return result;
}
public static ValidationResult MaskCheckRule(Integer id, Integer cnt, String target, ValidationRule rule)
{
ValidationResult result = new ValidationResult();
if (isValidId(id.intValue()) && cnt.intValue() > 0) {
result.setSuccess(true);
}
else if (isValid(target)) {
char [] valArray = target.toCharArray();
char [] maskArray = rule.other.toCharArray();
int len = valArray.length;
boolean success = (len == maskArray.length);
if (success)
{
char val;
char mask;
int m;
for(int i=0; i<len && success; i++)
{
val = valArray[i];
mask = maskArray[i];
switch(mask)
{
case 'X':
// The value must be a number
success = Character.isDigit(val);
break;
case 'A':
// the value must be a letter
success = Character.isLetter(val);
break;
default:
// these characters must match
success = (val == mask);
break;
}
}
}
result.setSuccess(success);
}
result.setErrorMessage("Please enter this value in the format requested.");
return result;
}