Validating EDI Data in Java

One of the most common requirements when dealing with EDI data is the need to validate messages. Last time, we looked at reading EDI data in Java which included a basic example of validating an X12 acknowledgment message. In that article, a sample schema (a set of validation rules) was given along with some basic Java code using the StAEDI library to set up the validator. This time, let's dig a little deeper into how the validator notifies an application about validation events and also discuss the differences between EDI standards and implementations — and how to validate both.

EDI Event Streams with Errors

While reading through an EDI message using the EDIStreamReader in StAEDI, the various structures found in the data are reported to an application as events. When a schema has been provided and the EDI data does not match the schema in some way, the invalid segments and elements are also reported as events as they are found in the data.