EDIFACTValidator Control

Properties   Methods   Events   Config Settings   Errors  

The EDIFACTValidator control validates EDIFACT documents against the specified standard, ensuring compliance and correctness.

Syntax

EDIFACTValidator

Remarks

This component provides a simple way to validate an EDI document and obtain details about any validation errors.

Before calling Validate call LoadSchema to load the schema for the document to be validated. The schema defines many validation rules such as minimum and maximum lengths, minimum and maximum occurrences, and more. The validation performed by the control depends largely on the schema's definition.

When the Validate method is called the control will attempt to validate the document. If errors are found during validation the ValidationErrors property will be populated with details of each error.

Inspect the ValidationErrors property for information on any errors that were encountered.

Validation Example validator.InputFile = @"C:\EDIFACT_Files\INVOIC_InvalidRepeat.edi"; validator.LoadSchema(@"C:\EDIFACT_Schemas\D97A.xml", "INVOIC"); validator.Validate(); foreach (EDIFACTValidationErrorDetail error in validator.ValidationErrors) { Console.WriteLine(error.ErrorCode + ": " + error.ErrorMessage); }

Property List


The following is the full list of the properties of the control with short descriptions. Click on the links for further details.

DelimiterComponentThe character used to separate the controls in a composite element.
DelimiterDecimalThe character used to separate the integer portion of a numeric value from the fractional portion.
DelimiterElementThe delimiter used to separate elements within a segment.
DelimiterReleaseThe character used to escape other characters within a property.
DelimiterRepetitionThe character used to indicate a repeating element or control.
DelimiterSegmentThe character used to terminate a segment.
InputDataThe EDI message, specified as a string.
InputFileThe file containing the EDI message.
ValidationErrorCountThe number of records in the ValidationError arrays.
ValidationErrorColumnThe column number where the error occurred.
ValidationErrorComponentIndexThis property holds the position of the element where the error occurred.
ValidationErrorElementIndexThis property holds the position of the element where the error occurred.
ValidationErrorErrorCodeThe ErrorCode property contains the type of error encountered.
ValidationErrorErrorMessageErrorMessage is a textual description of the error.
ValidationErrorErrorTypeIndicates the level of the document where the error was encountered.
ValidationErrorFGroupIndexThis property holds the position of the functional group where the error occurred.
ValidationErrorInterchangeIndexThis property holds the position of the interchange where the error occurred.
ValidationErrorLineThe line number where the error occurred.
ValidationErrorMessageIndexThis property holds the position of the message where the error occurred.
ValidationErrorPositionThis property holds the byte position in the EDI stream where the error occurred.
ValidationErrorSegmentIndexThis property is the index of the segment where the error occurred.
ValidationErrorSegmentTagThis property specifies the tag name of the segment where the error occurred.

Method List


The following is the full list of the methods of the control with short descriptions. Click on the links for further details.

ConfigSets or retrieves a configuration setting.
LoadSchemaLoads schema information from a file or string data.
ResetResets all properties to their default values.
ValidateValidate the EDI document and warn about any errors encountered.

Event List


The following is the full list of the events fired by the control with short descriptions. Click on the links for further details.

ErrorFires when an error occurs during message processing. Normally, the control fails with an error.
ResolveSchemaFires whenever a new EDIFACT message is encountered and no schema is found for it.
ValidateWarningFires to warn about validation errors.

Config Settings


The following is a list of config settings for the control with short descriptions. Click on the links for further details.

InputFormatThe format of the input EDIFACT document for validation.
MaxValidationErrorsThe maximum number of validation errors to return.

DelimiterComponent Property (EDIFACTValidator Control)

The character used to separate the controls in a composite element.

Syntax

edifactvalidatorcontrol.DelimiterComponent[=string]

Default Value

":"

Remarks

The character used to separate the components in a composite element.

This property is not available at design time.

Data Type

String

DelimiterDecimal Property (EDIFACTValidator Control)

The character used to separate the integer portion of a numeric value from the fractional portion.

Syntax

edifactvalidatorcontrol.DelimiterDecimal[=string]

Default Value

"."

Remarks

The character used to separate the integer portion of a numeric value from the fractional portion.

This property is not available at design time.

Data Type

String

DelimiterElement Property (EDIFACTValidator Control)

The delimiter used to separate elements within a segment.

Syntax

edifactvalidatorcontrol.DelimiterElement[=string]

Default Value

"+"

Remarks

The delimiter used to separate elements within a segment.

This property is not available at design time.

Data Type

String

DelimiterRelease Property (EDIFACTValidator Control)

The character used to escape other characters within a property.

Syntax

edifactvalidatorcontrol.DelimiterRelease[=string]

Default Value

"?"

Remarks

The character used to escape other characters within a field. For example, with the default EDIFACT delimiters, "?+" should be considered "+" character that appears within a field, not an element separator.

This property is not available at design time.

Data Type

String

DelimiterRepetition Property (EDIFACTValidator Control)

The character used to indicate a repeating element or control.

Syntax

edifactvalidatorcontrol.DelimiterRepetition[=string]

Default Value

"*(syntax 4) or empty(syntax 3)"

Remarks

The character used to indicate a repeating element or component.

This property is not available at design time.

Data Type

String

DelimiterSegment Property (EDIFACTValidator Control)

The character used to terminate a segment.

Syntax

edifactvalidatorcontrol.DelimiterSegment[=string]

Default Value

"'"

Remarks

The character used to terminate a segment.

This property is not available at design time.

Data Type

String

InputData Property (EDIFACTValidator Control)

The EDI message, specified as a string.

Syntax

edifactvalidatorcontrol.InputData[=string]

Default Value

""

Remarks

Set this property to specify the input EDI message as a string. The message can then be parsed with Parse.

This property is not available at design time.

Data Type

String

InputFile Property (EDIFACTValidator Control)

The file containing the EDI message.

Syntax

edifactvalidatorcontrol.InputFile[=string]

Default Value

""

Remarks

Set this property to specify a file to read the input EDI message from. The message can then be parsed with Parse.

This property is not available at design time.

Data Type

String

ValidationErrorCount Property (EDIFACTValidator Control)

The number of records in the ValidationError arrays.

Syntax

edifactvalidatorcontrol.ValidationErrorCount

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at ValidationErrorCount - 1.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorColumn Property (EDIFACTValidator Control)

The column number where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorColumn(ValidationErrorIndex)

Default Value

0

Remarks

The column number where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorComponentIndex Property (EDIFACTValidator Control)

This property holds the position of the element where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorComponentIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property holds the position of the element where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorElementIndex Property (EDIFACTValidator Control)

This property holds the position of the element where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorElementIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property holds the position of the element where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorErrorCode Property (EDIFACTValidator Control)

The ErrorCode property contains the type of error encountered.

Syntax

edifactvalidatorcontrol.ValidationErrorErrorCode(ValidationErrorIndex)

Default Value

"0"

Remarks

The ValidationErrorErrorCode property contains the type of error encountered.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

String

ValidationErrorErrorMessage Property (EDIFACTValidator Control)

ErrorMessage is a textual description of the error.

Syntax

edifactvalidatorcontrol.ValidationErrorErrorMessage(ValidationErrorIndex)

Default Value

""

Remarks

ValidationErrorErrorMessage is a textual description of the error.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

String

ValidationErrorErrorType Property (EDIFACTValidator Control)

Indicates the level of the document where the error was encountered.

Syntax

edifactvalidatorcontrol.ValidationErrorErrorType(ValidationErrorIndex)

Default Value

0

Remarks

Indicates the level of the document where the error was encountered. Possible values include:

1Interchange
2Functional group
3Message
4Segment
5Element

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorFGroupIndex Property (EDIFACTValidator Control)

This property holds the position of the functional group where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorFGroupIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property holds the position of the functional group where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorInterchangeIndex Property (EDIFACTValidator Control)

This property holds the position of the interchange where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorInterchangeIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property holds the position of the interchange where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorLine Property (EDIFACTValidator Control)

The line number where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorLine(ValidationErrorIndex)

Default Value

0

Remarks

The line number where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorMessageIndex Property (EDIFACTValidator Control)

This property holds the position of the message where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorMessageIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property holds the position of the message where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorPosition Property (EDIFACTValidator Control)

This property holds the byte position in the EDI stream where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorPosition(ValidationErrorIndex)

Default Value

0

Remarks

This property holds the byte position in the EDI stream where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Long64

ValidationErrorSegmentIndex Property (EDIFACTValidator Control)

This property is the index of the segment where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorSegmentIndex(ValidationErrorIndex)

Default Value

1

Remarks

This property is the index of the segment where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

Integer

ValidationErrorSegmentTag Property (EDIFACTValidator Control)

This property specifies the tag name of the segment where the error occurred.

Syntax

edifactvalidatorcontrol.ValidationErrorSegmentTag(ValidationErrorIndex)

Default Value

""

Remarks

This property specifies the tag name of the segment where the error occurred.

The ValidationErrorIndex parameter specifies the index of the item in the array. The size of the array is controlled by the ValidationErrorCount property.

This property is read-only and not available at design time.

Data Type

String

Config Method (EDIFACTValidator Control)

Sets or retrieves a configuration setting.

Syntax

edifactvalidatorcontrol.Config ConfigurationString

Remarks

Config is a generic method available in every control. It is used to set and retrieve configuration settings for the control.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the control, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

LoadSchema Method (EDIFACTValidator Control)

Loads schema information from a file or string data.

Syntax

edifactvalidatorcontrol.LoadSchema fileOrData, messageName

Remarks

This method loads schema information for use when parsing, validating, and translating messages.

The FileOrData parameter can be set to the path of a file containing schema data, or can be set to the contents of a schema file directly.

MessageName can be set to the name of a specific message to load only the specified message's schema information. If left empty or set to "*", the entire schema will be loaded.

Reset Method (EDIFACTValidator Control)

Resets all properties to their default values.

Syntax

edifactvalidatorcontrol.Reset 

Remarks

This method resets all properties of the component to their default values as specified in the property definitions.

Validate Method (EDIFACTValidator Control)

Validate the EDI document and warn about any errors encountered.

Syntax

edifactvalidatorcontrol.Validate 

Remarks

This method parses the input EDI document, firing the ValidateWarning event for any non-blocking errors it encounters.

Error Event (EDIFACTValidator Control)

Fires when an error occurs during message processing. Normally, the control fails with an error.

Syntax

Sub edifactvalidatorcontrol_Error(ErrorCode As Integer, Description As String)

Remarks

The Error event is fired in case of exceptional conditions during message processing. Normally, the control fails with an error.

ConnectionId is the associated client Id, ErrorCode contains an error code, and Description contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.

ResolveSchema Event (EDIFACTValidator Control)

Fires whenever a new EDIFACT message is encountered and no schema is found for it.

Syntax

Sub edifactvalidatorcontrol_ResolveSchema(MessageVersion As String, MessageType As String)

Remarks

This method fires when the control encounters an EDIFACT message it has not loaded a schema for. The parameters of the event can be used to locate the correct schema and load it with LoadSchema.

MessageVersion - The EDIFACT version of the message, such as D97A.

MessageType - The type of message, such as INVOIC.

After the event fires, if the control still doesn't have a matching schema, then it will attempt schema-less parsing of the EDIFACT message.

ValidateWarning Event (EDIFACTValidator Control)

Fires to warn about validation errors.

Syntax

Sub edifactvalidatorcontrol_ValidateWarning(Position As Long64, Line As Integer, Column As Integer, ErrorCode As String, ErrorMessage As String, ErrorType As Integer)

Remarks

When the control encounters a non-blocking error while validating a document, this event fires with information about the error.

Config Settings (EDIFACTValidator Control)

The control accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the control, access to these internal properties is provided through the Config method.

EDIFACTValidator Config Settings

InputFormat:   The format of the input EDIFACT document for validation.

This setting controls the type of input EDIFACT document for validation. Possible values are:

InputFormatMeaning
0 (default)EDIFACT
1XML
MaxValidationErrors:   The maximum number of validation errors to return.

This setting controls the maximum number of validation errors that will be returned during the validation process. The default value is 200.

Trappable Errors (EDIFACTValidator Control)

EDIFACTValidator Errors

20203    Invalid argument.
20305    Cannot write to file.
21004    Could not find the selected schema in the chosen file.
21100    Encountered an unexpected segment tag.
21101    Attempted to perform an action while the component was busy, or close an incomplete interchange.
21045    Tried to load an invalid schema file.
21202    The index is out of range.
21203    The selected ACK type is invalid.
21204    Encountered an error while validating the UNA segment.