EDI Error Context

You can validate EDI objects for compliance by invoking IsValid for every IEdiItem. When IsValid returns False then the EDI object is invalid and the MessageErrorContext object gets populated with information about the issues.

 

 

 


 

 

 

Message Error Context

The MessageErrorContext contains the following details:

 

 

 


 

 

 

Segment Error Context

The SegmentErrorContext is a container for all the issues found in a segment and has the following identification properties;

  • Name, this is the segment tag, e.g. BIG or DTM
  • Value, this is the actual value of the segment from the original EDI document
  • SpecType, this holds the type of the segment in the EDI template
  • Position, this is the position of the segment within its transaction, starting from ST or UNH which are at position 0

These properties should be sufficient to identify the whereabouts of any invalid segment in the original EDI document and to point to the corresponding class in the EDI template.

A SegmentErrorContext can contain multiple validation issues, for multiple data elements with errors for example. All the issues are listed under:

 

 

 


 

 

 

DataElement Error Context

The DataElementErrorContext is a container for all the issues found for a particular data element and has the following identification properties:

  • Name, this is either the code defined the complex data element:

or the code defined for the simple data element:

  • Value, this is the actual value of the data element from the original EDI document
  • Position, this is the position of the complex or simple data element within the segment

  • ComponentPosition, this is the position of the simple data element within the complex element. If the data element is part of a segment only, this is 0.

  • RepetitionPosition, this is the position of the composite or simple repeating data element within the List

These properties should be sufficient to identify the data elements that are invalid.

The last property of the DataElementErrorContext is Code which points to the exact data element error code.

The architecture of the error contexts allows EdiFabric's AckMan to generate fully compliant EDI acknowledgments with the correct error codes.

 

 

 


 

 

 

User-Friendly Error Messages

The MessageErrorContext provides a Flatten method that lists all the errors in a single table, such as:

[BGM at pos 3] [4345 at pos 6 with value 123456789ABC] DataElementTooLong

Custom error messages are possible by creating custom attributes (inherited from any of the validation attributes) or applying custom validation.

Was this article helpful?
3 out of 3 found this helpful