conditionally enforce Common Rule

conditionally enforce Common Rule

Old forum URL:

TSF posted on Friday, March 22, 2013

How would I go about setting up a common rule (for instance - a MinLength rule) but only enforce it if the user populates the field with data. For instance, a fax number field isn't required, but if it is populated it must have a minimum length of 10. But as it stands currently, the MinLength rule fails if it isn't populated. Thanks.

JonnyBee replied on Friday, March 22, 2013


A couple of possibilities:

  1. You could subclass the MinLength rule and add an extra condition befor calling base.Execute. 
  2. You could crete a Gateway rule to check for has value and then call the inner rule. This would work with any (sync) rule.

For #2 look at the RuleTutorial sample for other gateway rules like CanWrite (only validate field if user is allowed to edit field).

Copyright (c) Marimer LLC