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:

  1. 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.
  2. 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:

  1. Calling IValidate.Validate on a feature yields the appropriate validation error message as expected.
  2. Calling IValidate.GetInvalidRules on 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.

  • i think you meant IValidate.GetInvalidRules ..
    – vinayan
    Sep 3 '12 at 9:26
  • is there a quick way to create an error in connectivity for a feature manually?
    – vinayan
    Sep 3 '12 at 14:29
  • @vinayan: Yes, but one needs to define the geometric network's connectivity rules first. These are typically set through ArcCatalog. It is very easy to set up, e.g., a rule where a junction must be connected to exactly one edge, and subsequently violate that rule by creating two adjacent edges.
    – Petr Krebs
    Sep 3 '12 at 18:43
  • Did you try calling IEnumRule.Reset before calling Next()? Sep 5 '12 at 1:39
  • @Kirk: As with every enumeration in ArcObjects, yes.
    – Petr Krebs
    Sep 5 '12 at 8:00

According to ESRI support, this behavior is indeed a bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.