Tools

Check Value with Tailored Algorithm

You can implement a custom rule via the CodeRule attribute. Code rules are usually designed for the following purposes:
- to check an object using a highly tailored algorithm;
- to apply a rule to an object that is implemented in a referenced assembly, without using the Model Editor.
Here, a custom rule is implemented for the CodeRuleObject type objects. It uses the following algorithm to check objects:
- if PersonName is not specified, a validation error is raised;
- if PersonName is specified, Sex is set to Male, but TitleOfCourtesy is not set to "Mr", a validation error is raised;
- if PersonName is specified, Sex is set to Female, but TitleOfCourtesy is set to "Mr", a validation error is raised;
- in other cases, the rule is valid.
For each case a rule is broken, a message template is specified to be written in the Validation Error window.
This rule is checked when saving an object.
 
Name AscendingNot filtered
Person Name Not filtered
Sex Not filtered
Title Of Courtesy Not filtered
EditInvalid CodeRuleObject 1 MaleMrs
EditInvalid CodeRuleObject 2MaryFemaleMr
EditValid CodeRuleObjectJohnMaleMr
Page 1 of 1 (3 items)Prev1Next v