X12Validator Component

Properties   Methods   Events   Config Settings   Errors  

The X12Validator component validates X12 documents against the specified standard, ensuring compliance and correctness.

Syntax

TedX12Validator

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 component depends largely on the schema's definition.

When the Validate method is called the component 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:\X12_Files\810_InvalidRepeat.txt"; validator.LoadSchema(@"C:\X12_Schemas\4010.xml", "810"); validator.Validate(); foreach (X12ValidationErrorDetail error in validator.ValidationErrors) { Console.WriteLine(error.ErrorCode + ": " + error.ErrorMessage); }

Property List


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

DelimiterComponentThe delimiter separating components.
DelimiterElementThe delimiter separating elements.
DelimiterRepetitionThe delimiter separating components.
DelimiterSegmentThe delimiter separating segments.
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 component 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.
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.
ValidationErrorTransactionSetIndexThis property holds the position of the message where the error occurred.

Method List


The following is the full list of the methods of the component 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 component with short descriptions. Click on the links for further details.

ErrorFires when a parsing error occurs.
ResolveSchemaFires to request schema information for a specific transaction set.
ValidateWarningFires to warn about validation errors.

Config Settings


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

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

DelimiterComponent Property (X12Validator Component)

The delimiter separating components.

Syntax

__property String DelimiterComponent = { read=FDelimiterComponent, write=FSetDelimiterComponent };

Default Value

":"

Remarks

The delimiter separating components.

In X12Reader, this type is used to hold the delimiters found when parsing the component, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterElement Property (X12Validator Component)

The delimiter separating elements.

Syntax

__property String DelimiterElement = { read=FDelimiterElement, write=FSetDelimiterElement };

Default Value

"*"

Remarks

The delimiter separating elements.

In X12Reader, this type is used to hold the delimiters found when parsing the element, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterRepetition Property (X12Validator Component)

The delimiter separating components.

Syntax

__property String DelimiterRepetition = { read=FDelimiterRepetition, write=FSetDelimiterRepetition };

Default Value

"^"

Remarks

The delimiter separating components.

In X12Reader, this type is used to hold the delimiters found when parsing the component, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

DelimiterSegment Property (X12Validator Component)

The delimiter separating segments.

Syntax

__property String DelimiterSegment = { read=FDelimiterSegment, write=FSetDelimiterSegment };

Default Value

"~"

Remarks

The delimiter separating segments.

In X12Reader, this type is used to hold the delimiters found when parsing the segment, while in X12Writer the fields can be set to choose the delimiters that will be used when writing

This property is not available at design time.

Data Type

String

InputData Property (X12Validator Component)

The EDI message, specified as a string.

Syntax

__property String InputData = { read=FInputData, write=FSetInputData };

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 (X12Validator Component)

The file containing the EDI message.

Syntax

__property String InputFile = { read=FInputFile, write=FSetInputFile };

Default Value

""

Remarks

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

If the file is not found or cannot be opened, an error will be returned.

Note: If both InputFile and InputData are set, InputData takes precedence.

This property is not available at design time.

Data Type

String

ValidationErrorCount Property (X12Validator Component)

The number of records in the ValidationError arrays.

Syntax

__property int ValidationErrorCount = { read=FValidationErrorCount };

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 (X12Validator Component)

The column number where the error occurred.

Syntax

__property int ValidationErrorColumn[int ValidationErrorIndex] = { read=FValidationErrorColumn };

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 (X12Validator Component)

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

Syntax

__property int ValidationErrorComponentIndex[int ValidationErrorIndex] = { read=FValidationErrorComponentIndex };

Default Value

1

Remarks

This property holds the position of the component 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 (X12Validator Component)

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

Syntax

__property int ValidationErrorElementIndex[int ValidationErrorIndex] = { read=FValidationErrorElementIndex };

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 (X12Validator Component)

The ErrorCode property contains the type of error encountered.

Syntax

__property String ValidationErrorErrorCode[int ValidationErrorIndex] = { read=FValidationErrorErrorCode };

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 (X12Validator Component)

ErrorMessage is a textual description of the error.

Syntax

__property String ValidationErrorErrorMessage[int ValidationErrorIndex] = { read=FValidationErrorErrorMessage };

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 (X12Validator Component)

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

Syntax

__property int ValidationErrorErrorType[int ValidationErrorIndex] = { read=FValidationErrorErrorType };

Default Value

0

Remarks

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

1Interchange
2Functional group
3Transaction set
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 (X12Validator Component)

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

Syntax

__property int ValidationErrorFGroupIndex[int ValidationErrorIndex] = { read=FValidationErrorFGroupIndex };

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 (X12Validator Component)

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

Syntax

__property int ValidationErrorInterchangeIndex[int ValidationErrorIndex] = { read=FValidationErrorInterchangeIndex };

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 (X12Validator Component)

The line number where the error occurred.

Syntax

__property int ValidationErrorLine[int ValidationErrorIndex] = { read=FValidationErrorLine };

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

ValidationErrorPosition Property (X12Validator Component)

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

Syntax

__property __int64 ValidationErrorPosition[int ValidationErrorIndex] = { read=FValidationErrorPosition };

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 (X12Validator Component)

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

Syntax

__property int ValidationErrorSegmentIndex[int ValidationErrorIndex] = { read=FValidationErrorSegmentIndex };

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 (X12Validator Component)

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

Syntax

__property String ValidationErrorSegmentTag[int ValidationErrorIndex] = { read=FValidationErrorSegmentTag };

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

ValidationErrorTransactionSetIndex Property (X12Validator Component)

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

Syntax

__property int ValidationErrorTransactionSetIndex[int ValidationErrorIndex] = { read=FValidationErrorTransactionSetIndex };

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

Config Method (X12Validator Component)

Sets or retrieves a configuration setting.

Syntax

String __fastcall Config(String ConfigurationString);

Remarks

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

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the component, 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 (X12Validator Component)

Loads schema information from a file or string data.

Syntax

void __fastcall LoadSchema(String fileOrData, String 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 (X12Validator Component)

Resets all properties to their default values.

Syntax

void __fastcall Reset();

Remarks

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

Validate Method (X12Validator Component)

Validate the EDI document and warn about any errors encountered.

Syntax

void __fastcall Validate();

Remarks

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

Error Event (X12Validator Component)

Fires when a parsing error occurs.

Syntax

typedef struct {
  int ErrorCode;
  String Description;
} TedX12ValidatorErrorEventParams;
typedef void __fastcall (__closure *TedX12ValidatorErrorEvent)(System::TObject* Sender, TedX12ValidatorErrorEventParams *e);
__property TedX12ValidatorErrorEvent OnError = { read=FOnError, write=FOnError };

Remarks

This event fires when the component encounters a parsing error while processing a document.

ResolveSchema Event (X12Validator Component)

Fires to request schema information for a specific transaction set.

Syntax

typedef struct {
  String VersionNumber;
  String TransactionSetIDCode;
} TedX12ValidatorResolveSchemaEventParams;
typedef void __fastcall (__closure *TedX12ValidatorResolveSchemaEvent)(System::TObject* Sender, TedX12ValidatorResolveSchemaEventParams *e);
__property TedX12ValidatorResolveSchemaEvent OnResolveSchema = { read=FOnResolveSchema, write=FOnResolveSchema };

Remarks

LoadSchema can be called from within this event to load the schema information for the specified transaction set.

ValidateWarning Event (X12Validator Component)

Fires to warn about validation errors.

Syntax

typedef struct {
  __int64 Position;
  int Line;
  int Column;
  String ErrorCode;
  String ErrorMessage;
  int ErrorType;
} TedX12ValidatorValidateWarningEventParams;
typedef void __fastcall (__closure *TedX12ValidatorValidateWarningEvent)(System::TObject* Sender, TedX12ValidatorValidateWarningEventParams *e);
__property TedX12ValidatorValidateWarningEvent OnValidateWarning = { read=FOnValidateWarning, write=FOnValidateWarning };

Remarks

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

Config Settings (X12Validator Component)

The component 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 component, access to these internal properties is provided through the Config method.

X12Validator Config Settings

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

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

InputFormatMeaning
0 (default)X12
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 (X12Validator Component)

X12Validator Errors

202   Invalid argument.
304   Cannot write to file.
1003   Could not find the selected schema in the chosen file.
1099   Encountered an unexpected segment tag.
1100   Attempted to perform an action while the component was busy, or close an incomplete interchange.
1044   Tried to load an invalid schema file.
1201   The index is out of range.
1202   The selected ACK type is invalid.
1203   Encountered an error while validating the UNA segment.