EDI Validation Settings

To control how EDI transactions are being validated, pass in a ValidationSettings object to the IsValid method of EdiMessage.

ValidationSettings settings = new ValidationSettings();
settings.SkipTrailerValidation= true;
settings.DecimalPoint = '.';
settings.SyntaxSet = new Basic();
settings.DataElementTypeMap = new Dictionary<Type, Type>();
settings.DataElementCodesMap = new public Dictionary<string, List<string>>();

ediMessage.IsValid(out errorContext, settings);

You can select any of the following settings:

  • SkipTrailerValidation - whether to skip trailer validation in messages ('false' by default). This is useful when you are generating a POCO and haven't created any trailer segments, such as SE or UNZ, because they will be automatically appended by the EdiWriter. This flag tells the validator to skip over any validation that includes trailer segments.
  • DecimalPoint - The decimal point for Edifact only ('.' by default).
  • SyntaxSet - The syntax set used to validate alphanumeric data types (not set by default). Read about EDIFACT data element validation and X12 data element validation for additional information.
  • DataElementTypeMap - allows you to apply different sets of EDI Codes than the ones in the EDI Template.
  • DiscardValidationAttributes - allows you to turn off validation even when using the Enterprise templates. This is useful for situations when a trading partner only requires HIPAA SNIP Type 1 validation.
  • DataElementCodesMap - allows you to import external EDI codes at runtime.

 

 

 


 

 

 

DataElementCodesMap

Let's assume that Partner A specifies custom EDI Codes for the Transaction Set Purpose Code X12_ID_35. The standard definition for X12, version 4010 being:

/// 
/// Transaction Set Purpose Code
/// 
[Serializable()]
[DataContract()]
[EdiCodes(",00,01,02,03,04,05,06,07,08,10,11,12,13,14,15,16,17," +
"18,19,20,21,22,24,25,26,27,28,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44," +
"45,46,47,48,49,50,51,52,53,54,55,5,6,5C,77,CN,CO,EX,GR,PR,RH,RV,SU,ZZ,")]
public class X12_ID_353
{
}

Partner A, however, defines it as a set of only two, not included in the standard values: "PA" and "PB". Partner A also requires that these EDI codes might change over time and should be validated against without having to redeploy or rebuild EdiFabric's templates.

By default when the EDI Template for the standard 850 is used, calling IsValid() will check the values from X12_ID_353, but we want it to check against the values from the external EDI codes for Partner A, dynamically, without any rebuilding or redeployments.

This is possible by including an EDI Code map as a parameter to IsValid().

var codeSetMap = new Dictionary<string, List<string>>();
codeSetMap.Add("X12_ID_353", new List<string> { "PA", "PB" });

purchaseOrder.IsValid(out errorContext,
new ValidationSettings { DataElementCodesMap = codeSetMap });

Use this method to dynamically load external Code sets from file or database. The Code set type name is the key and the EDI codes are specified as a list of strings.

 

 

 


 

 

 

DataElementTypeMap

Let's assume that Partner A specifies custom EDI Codes for the Transaction Set Purpose Code X12_ID_35. The standard definition for X12, version 4010 being:

/// 
/// Transaction Set Purpose Code
/// 
[Serializable()]
[DataContract()]
[EdiCodes(",00,01,02,03,04,05,06,07,08,10,11,12,13,14,15,16,17," +
"18,19,20,21,22,24,25,26,27,28,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44," +
"45,46,47,48,49,50,51,52,53,54,55,5,6,5C,77,CN,CO,EX,GR,PR,RH,RV,SU,ZZ,")]
public class X12_ID_353
{
}

Partner A, however, defines it as a set of only two, not included in the standard values:

/// 
/// Transaction Set Purpose Code
/// 
[Serializable()]
[DataContract()]
[EdiCodes(",PA,PB,")]
public class X12_ID_353_PartnerA
{
}

By default when the EDI Template for the standard 850 is used, calling IsValid() will check the values from X12_ID_353, but we want it to check against the values from X12_ID_353_PartnerA regardless.

This is possible by including an EDI Code map as a parameter to IsValid().

Dictionary<Type, Type> codeSetMap = new Dictionary<Type, Type>();
codeSetMap.Add(typeof(X12_ID_353), typeof(X12_ID_353_PartnerA));

purchaseOrder.IsValid(out errorContext,
new ValidationSettings { DataElementTypeMap = codeSetMap });

 

 

 


 

 

 

SyntaxSet

By default, data types such as allowed characters in alpha and alphanumeric types are not validated. To enable this validation pass in the relevant syntax set as part of the validation settings:

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