EDI EDIFACT Data Element Validation

EDIFACT Data Types

EdiFabric supports the following data element types.

Numeric

A data element can include digits and decimal mark (either point or comma is acceptable for this).

EDIFACT notation combines the type and length as in the following examples:

n..9 up to nine digits

n9 exactly nine digits

If the element has variable length, omit leading zeros and trailing spaces unless significant. A single zero before a decimal is significant, and a zero may be significant if the element’s specification states that it is.

Signs and decimals don’t count toward maximum field length. The sign must be omitted unless negative.

If the number is fractional, include the decimal mark. If a decimal mark is included in the EDI file, include at least one digit before and after it. Do not include decimals for integers unless needed to indicate precision.

The official representation for the decimal mark is the comma. If a UNA is included, its third character specifies the decimal mark.

The DOM C# class representing numeric EDIFACT data type is:

 [Serializable()]
 public class EDIFACT_N
 {
 } 

 

 

 


 

 

 

Alphabetic

Data element can include any letters, special characters, and control characters but no digits.

EDIFACT notation combines the type and length as in the following examples:

a3 exactly 3 alphabetic characters.

a..3 up to three alphabetic characters.

The DOM C# class representing alphabetic EDIFACT data type is:

 [Serializable()]
 public class EDIFACT_A
 {
 } 

 

 

 


 

 

 

Alphanumeric

Data element can include any letters, digits, special characters, and control characters.

EDIFACT notation combines the type and length as in the following examples:

an5 exactly 5 alphanumeric characters

an..5 up to 5 alphanumeric characters.

The DOM C# class representing alphanumeric EDIFACT data type is:

 [Serializable()]
 public class EDIFACT_AN
 {
 } 

 

 

 


 

 

 

EDIFACT Data Types Validation

By default, alphabetic or alphanumeric strings are not validated for invalid characters. To enable this type of validation, an implementation of a SyntxSet must be passed to either the IsValid method of EdiMessage or the EdifactReader constructor (when using splitting only).

The following syntax set implementations are available:

 

 

 


 

 

 

UNOA

Valid characters are:

ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,–() /=

 MessageErrorContext result;
 var validationResult = msg.IsValid(out result, 
new ValidationSettings { SyntaxSet = new Unoa()});

 

 

 


 

 

 

UNOB

Valid characters are:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,–() /=‘+:?!”%&*;<>'""

 MessageErrorContext result;
 var validationResult = msg.IsValid(out result, 
new ValidationSettings { SyntaxSet = new Unob()});

 

 

 


 

 

 

Custom

Use CustomSyntax to specify a custom set of chars for all A or AN data types.

 MessageErrorContext result;
 var validationResult = msg.IsValid(out result, 
new ValidationSettings {
SyntaxSet = new CustomSyntax(new Unoa().GetValidChars() + "ß")});

 

 

 


 

 

 

Regex

Use RegexSyntax to specify a custom regex for all A or AN data types.

 MessageErrorContext result;
 var validationResult = msg.IsValid(out result, 
new ValidationSettings {
SyntaxSet = new RegexSyntax(new Regex("[a-zA-Z0-9 ]"))});

 

 

 


 

 

 

Override syntax set validation at the data element level

All validation is applied on type level, that is all data elements with AN or A type will be validated towards the specified syntax set. Sometimes it is required that a particular data element needs to be validated differently and at the same time maintain the overall syntax validation for the remainder of the data elements. This can be achieved by overriding the syntax validation at the data element level:

[DataElement("5286", typeof(EDIFACT_AN), @"^[A-Za-z0-9., %]*$")]
[Pos(4)]
public string Dutyortaxorfeeassessmentbasisvalue_04 { get; set; }

Specifying a Regex expression directly at the data element overrides the syntax set specified at the ValidationSettings for this data element only.

Was this article helpful?
5 out of 6 found this helpful