we are currently trying to programmatically validate features against geodatabase-defined rules. This includes attribute rules as well as connectivity and relationship rules.
We have consulted the documentation for IValidate, IValidation and the Validating features article on EDN to learn how it's done.
After setting up the appropriate connectivity rules, invocation of the Validate Features in ArcMap correctly yields the number of invalid features in a selection. If I select a single feature, invocation of this command correctly displays what is wrong about that particular feature in a message box.
Now, calling IValidate.Validate on that feature works as well. Its return value indicates that the feature is indeed invalid, and the error message is identical to that displayed by the Validate Features command in ArcMap. However, calling this method has two disadvantages which are problematic for our purposes:
- It performs the validation in a short-circuit manner. As soon as one of the assigned rules is invalid, it stops evaluating the remaining rules. We need to evaluate all the rules so that we can display the violations at once.
- It provides the error information as a string. For our purposes, we would ideally like to examine the information in a more structured way, which means we need to access the IRules that turned out to be invalid.
So, this is where IValidate.GetInvalidRules comes into play. The documentation for this method states:
The GetInvalidRules method returns an enumerator of rules that are currently violated by the row.
which is exactly what we are after. However, the enumeration returned by this method does not seem to ever contain anything. What is particularly weird is that:
- Calling
IValidate.Validateon a feature yields the appropriate validation error message as expected. - Calling
IValidate.GetInvalidRuleson the very same feature always returns an empty enumeration as if no connectivity or relationship rules were invalid. (It does not matter whether the call is made within an edit session or not.)
How can I validate a row against all the assigned geodatabase rules at once? Has anyone used IValidate.GetInvalidRules successfully?
UPDATE: IValidate.GetInvalidRules seems to return invalid rules which pertain to attributes. However, invalid network connectivity rules are still never returned from this method.