Index
Validating EDI Files I
Validating EDI files is extremely simple. Just set a few properties and you’re ready to go.
Example
// Create an instance of the EDIValidator object
EDIValidator validator = new EDIValidator();
// Set the EDI rules file.
validator.EDIRulesFile = “C:\\EDIFile.Rules”;
// Set the EDI file to validate
validator.EDIFile = “C:\\EDIFile.txt”;
// Validate
validator.Validate();
// Check if the EDI file passed
if (validator.Passed)
{
//Get the EDI file just parsed
EDILightWeightDocument file = validator.EDILightWeightDocument;
}
else
{
//Display all errors
foreach (EDIError error in ediValidator.Errors)
{
Console.WriteLine(error.LineNumber.ToString() + ” ” + error.Loop + ” ” + error.Segment + ” ” + error.Message.ToString());
}
}
The EDIError object has many properties to help you debug your file.