Cross-field validation

The solution to the problem described above is to delay postal/ZIP code checks until IXF exit time. At that point, all field changes should have been completed and it is perfectly sensible to check whether the postal/ZIP code field contains data valid for the country, as specified by the country field. Any error message generated should mention both fields so that the user is not left wondering why the system is complaining about a field containing perfectly good data.

In fact, at this point, any group of related fields can be checked against each other, against a table of acceptable combinations, or whatever. For example, the postal/ZIP code, country, city, state or province, and phone number might all be examined in an address validation exit.

The difficulty for the developer is deciding what should be checked and when. Deciding when is straightforward. To avoid unpredictable combinations of interdependent field data, some things can only be handled at IXF exit time. Any validation possible at the field level may also be delayed until IXF time if the developer finds this convenient. The difference is that, if set up as an FOB or FOA exit, the code will run every time the field is changed. However, if included in the IXF exit, it will run whenever any field of the row has changed and some output action is requested or ENTER has been pressed.

Deciding what to validate is more difficult. On the one hand, you want to validate as thoroughly as possible in order to catch errors before they have consequences, and to make the system’s output as reliable as possible. On the other hand, the development effort and execution overhead for validation routines must be factored into the equation. When in doubt, lean toward thorough validation, particularly at IXF time, provided that validation rules are clearly specified.

Implementing a comprehensive address validation exit, for example, is tempting. Address information with essentially the same set of fields turns up in many different areas which could be subject to validation.

Unfortunately, with real world data, the rules are not always clear. Someone with a New Jersey phone number might get mail via an address at the company’s New York headquarters, so just checking ZIP code versus area code doesn’t always work.