EDIFACTValidator Class
Properties Methods Events Config Settings Errors
The EDIFACTValidator class validates EDIFACT documents against the specified standard, ensuring compliance and correctness.
Class Name
EDISDK_EDIFACTValidator
Procedural Interface
edisdk_edifactvalidator_open(); edisdk_edifactvalidator_close($res); edisdk_edifactvalidator_register_callback($res, $id, $function); edisdk_edifactvalidator_get_last_error($res); edisdk_edifactvalidator_get_last_error_code($res); edisdk_edifactvalidator_set($res, $id, $index, $value); edisdk_edifactvalidator_get($res, $id, $index); edisdk_edifactvalidator_do_config($res, $configurationstring); edisdk_edifactvalidator_do_loadschema($res, $fileordata, $messagename); edisdk_edifactvalidator_do_reset($res); edisdk_edifactvalidator_do_validate($res);
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 class depends largely on the schema's definition.
When the Validate method is called the class 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 class with short descriptions. Click on the links for further details.
| DelimiterComponent | The character used to separate the classes in a composite element. |
| DelimiterDecimal | The character used to separate the integer portion of a numeric value from the fractional portion. |
| DelimiterElement | The delimiter used to separate elements within a segment. |
| DelimiterRelease | The character used to escape other characters within a property. |
| DelimiterRepetition | The character used to indicate a repeating element or class. |
| DelimiterSegment | The character used to terminate a segment. |
| InputData | The EDI message, specified as a string. |
| InputFile | The file containing the EDI message. |
| ValidationErrorCount | The number of records in the ValidationError arrays. |
| ValidationErrorColumn | The column number where the error occurred. |
| ValidationErrorComponentIndex | This property holds the position of the element where the error occurred. |
| ValidationErrorElementIndex | This property holds the position of the element where the error occurred. |
| ValidationErrorErrorCode | The ErrorCode property contains the type of error encountered. |
| ValidationErrorErrorMessage | ErrorMessage is a textual description of the error. |
| ValidationErrorErrorType | Indicates the level of the document where the error was encountered. |
| ValidationErrorFGroupIndex | This property holds the position of the functional group where the error occurred. |
| ValidationErrorInterchangeIndex | This property holds the position of the interchange where the error occurred. |
| ValidationErrorLine | The line number where the error occurred. |
| ValidationErrorMessageIndex | This property holds the position of the message where the error occurred. |
| ValidationErrorPosition | This property holds the byte position in the EDI stream where the error occurred. |
| ValidationErrorSegmentIndex | This property is the index of the segment where the error occurred. |
| ValidationErrorSegmentTag | This 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 class with short descriptions. Click on the links for further details.
| Config | Sets or retrieves a configuration setting. |
| LoadSchema | Loads schema information from a file or string data. |
| Reset | Resets all properties to their default values. |
| Validate | Validate the EDI document and warn about any errors encountered. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
| Error | Fires when an error occurs during message processing. Normally, the class fails with an error. |
| ResolveSchema | Fires whenever a new EDIFACT message is encountered and no schema is found for it. |
| ValidateWarning | Fires to warn about validation errors. |
Config Settings
The following is a list of config settings for the class with short descriptions. Click on the links for further details.
| InputFormat | The format of the input EDIFACT document for validation. |
| MaxValidationErrors | The maximum number of validation errors to return. |
DelimiterComponent Property (EDISDK_EDIFACTValidator Class)
The character used to separate the classes in a composite element.
Object Oriented Interface
public function getDelimiterComponent(); public function setDelimiterComponent($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 1 ); edisdk_edifactvalidator_set($res, 1, $value );
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 (EDISDK_EDIFACTValidator Class)
The character used to separate the integer portion of a numeric value from the fractional portion.
Object Oriented Interface
public function getDelimiterDecimal(); public function setDelimiterDecimal($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 2 ); edisdk_edifactvalidator_set($res, 2, $value );
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 (EDISDK_EDIFACTValidator Class)
The delimiter used to separate elements within a segment.
Object Oriented Interface
public function getDelimiterElement(); public function setDelimiterElement($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 3 ); edisdk_edifactvalidator_set($res, 3, $value );
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 (EDISDK_EDIFACTValidator Class)
The character used to escape other characters within a property.
Object Oriented Interface
public function getDelimiterRelease(); public function setDelimiterRelease($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 4 ); edisdk_edifactvalidator_set($res, 4, $value );
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 (EDISDK_EDIFACTValidator Class)
The character used to indicate a repeating element or class.
Object Oriented Interface
public function getDelimiterRepetition(); public function setDelimiterRepetition($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 5 ); edisdk_edifactvalidator_set($res, 5, $value );
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 (EDISDK_EDIFACTValidator Class)
The character used to terminate a segment.
Object Oriented Interface
public function getDelimiterSegment(); public function setDelimiterSegment($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 6 ); edisdk_edifactvalidator_set($res, 6, $value );
Default Value
'''
Remarks
The character used to terminate a segment.
This property is not available at design time.
Data Type
String
InputData Property (EDISDK_EDIFACTValidator Class)
The EDI message, specified as a string.
Object Oriented Interface
public function getInputData(); public function setInputData($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 7 ); edisdk_edifactvalidator_set($res, 7, $value );
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 (EDISDK_EDIFACTValidator Class)
The file containing the EDI message.
Object Oriented Interface
public function getInputFile(); public function setInputFile($value);
Procedural Interface
edisdk_edifactvalidator_get($res, 8 ); edisdk_edifactvalidator_set($res, 8, $value );
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 (EDISDK_EDIFACTValidator Class)
The number of records in the ValidationError arrays.
Object Oriented Interface
public function getValidationErrorCount();
Procedural Interface
edisdk_edifactvalidator_get($res, 9 );
Default Value
0
Remarks
This property controls the size of the following arrays:
- ValidationErrorColumn
- ValidationErrorComponentIndex
- ValidationErrorElementIndex
- ValidationErrorErrorCode
- ValidationErrorErrorMessage
- ValidationErrorErrorType
- ValidationErrorFGroupIndex
- ValidationErrorInterchangeIndex
- ValidationErrorLine
- ValidationErrorMessageIndex
- ValidationErrorPosition
- ValidationErrorSegmentIndex
- ValidationErrorSegmentTag
This property is read-only and not available at design time.
Data Type
Integer
ValidationErrorColumn Property (EDISDK_EDIFACTValidator Class)
The column number where the error occurred.
Object Oriented Interface
public function getValidationErrorColumn($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 10 , $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 (EDISDK_EDIFACTValidator Class)
This property holds the position of the element where the error occurred.
Object Oriented Interface
public function getValidationErrorComponentIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 11 , $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 (EDISDK_EDIFACTValidator Class)
This property holds the position of the element where the error occurred.
Object Oriented Interface
public function getValidationErrorElementIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 12 , $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 (EDISDK_EDIFACTValidator Class)
The ErrorCode property contains the type of error encountered.
Object Oriented Interface
public function getValidationErrorErrorCode($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 13 , $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 (EDISDK_EDIFACTValidator Class)
ErrorMessage is a textual description of the error.
Object Oriented Interface
public function getValidationErrorErrorMessage($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 14 , $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 (EDISDK_EDIFACTValidator Class)
Indicates the level of the document where the error was encountered.
Object Oriented Interface
public function getValidationErrorErrorType($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 15 , $validationerrorindex);
Default Value
0
Remarks
Indicates the level of the document where the error was encountered. Possible values include:
| 1 | Interchange |
| 2 | Functional group |
| 3 | Message |
| 4 | Segment |
| 5 | Element |
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 (EDISDK_EDIFACTValidator Class)
This property holds the position of the functional group where the error occurred.
Object Oriented Interface
public function getValidationErrorFGroupIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 16 , $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 (EDISDK_EDIFACTValidator Class)
This property holds the position of the interchange where the error occurred.
Object Oriented Interface
public function getValidationErrorInterchangeIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 17 , $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 (EDISDK_EDIFACTValidator Class)
The line number where the error occurred.
Object Oriented Interface
public function getValidationErrorLine($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 18 , $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 (EDISDK_EDIFACTValidator Class)
This property holds the position of the message where the error occurred.
Object Oriented Interface
public function getValidationErrorMessageIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 19 , $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 (EDISDK_EDIFACTValidator Class)
This property holds the byte position in the EDI stream where the error occurred.
Object Oriented Interface
public function getValidationErrorPosition($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 20 , $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 (EDISDK_EDIFACTValidator Class)
This property is the index of the segment where the error occurred.
Object Oriented Interface
public function getValidationErrorSegmentIndex($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 21 , $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 (EDISDK_EDIFACTValidator Class)
This property specifies the tag name of the segment where the error occurred.
Object Oriented Interface
public function getValidationErrorSegmentTag($validationerrorindex);
Procedural Interface
edisdk_edifactvalidator_get($res, 22 , $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 (EDISDK_EDIFACTValidator Class)
Sets or retrieves a configuration setting.
Object Oriented Interface
public function doConfig($configurationstring);
Procedural Interface
edisdk_edifactvalidator_do_config($res, $configurationstring);
Remarks
Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, 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 (EDISDK_EDIFACTValidator Class)
Loads schema information from a file or string data.
Object Oriented Interface
public function doLoadSchema($fileordata, $messagename);
Procedural Interface
edisdk_edifactvalidator_do_loadschema($res, $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 (EDISDK_EDIFACTValidator Class)
Resets all properties to their default values.
Object Oriented Interface
public function doReset();
Procedural Interface
edisdk_edifactvalidator_do_reset($res);
Remarks
This method resets all properties of the component to their default values as specified in the property definitions.
Validate Method (EDISDK_EDIFACTValidator Class)
Validate the EDI document and warn about any errors encountered.
Object Oriented Interface
public function doValidate();
Procedural Interface
edisdk_edifactvalidator_do_validate($res);
Remarks
This method parses the input EDI document, firing the ValidateWarning event for any non-blocking errors it encounters.
Error Event (EDISDK_EDIFACTValidator Class)
Fires when an error occurs during message processing. Normally, the class fails with an error.
Object Oriented Interface
public function fireError($param);
Procedural Interface
edisdk_edifactvalidator_register_callback($res, 1, array($this, 'fireError'));
Parameter List
'errorcode'
'description'
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally, the class 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 (EDISDK_EDIFACTValidator Class)
Fires whenever a new EDIFACT message is encountered and no schema is found for it.
Object Oriented Interface
public function fireResolveSchema($param);
Procedural Interface
edisdk_edifactvalidator_register_callback($res, 2, array($this, 'fireResolveSchema'));
Parameter List
'messageversion'
'messagetype'
Remarks
This method fires when the class 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 class still doesn't have a matching schema, then it will attempt schema-less parsing of the EDIFACT message.
ValidateWarning Event (EDISDK_EDIFACTValidator Class)
Fires to warn about validation errors.
Object Oriented Interface
public function fireValidateWarning($param);
Procedural Interface
edisdk_edifactvalidator_register_callback($res, 3, array($this, 'fireValidateWarning'));
Parameter List
'position'
'line'
'column'
'errorcode'
'errormessage'
'errortype'
Remarks
When the class encounters a non-blocking error while validating a document, this event fires with information about the error.
Config Settings (EDIFACTValidator Class)
The class 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 class, access to these internal properties is provided through the Config method.EDIFACTValidator Config Settings
| InputFormat | Meaning |
| 0 (default) | EDIFACT |
| 1 | XML |
Trappable Errors (EDIFACTValidator Class)
EDIFACTValidator 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. |