Validators

A few scenarios require you to perform cross-field validations in the business document schema. For example, a certain condition can be based on another field in the document, or a certain field may need to adhere to a length limit for the business transformation logic to process the document schema .

Different types of validators are available for records, composites, and other fields. Validation is possible for:

  • Records and composites by using conditional validators. ​
  • Fields by using either length or code list validators.

Conditional validators

The conditional validators are used with all other validation attributes and are applied when the document is processed.

Follow the syntax rules that are created by the EDI Standards bodies ANSI X12 or UN/EDIFACT to specify conditional validators for a record or composite, regardless of the type of document you use.

Anatomy of the validator property in an ANSI X12 document in the document string C 01 02 C 03 04 05, the character C represents the code, and the numerals 01, 02, 03, 04, and 05 represent the fields.

A conditional validator refers to the location of the field in a definition, not the location of the data in a business document. For example, if you switched the extractors for the first and second field such that the first field extracts the value in Field_II and the second field extracts the value in Field_I, the conditional validator indicates that if Field_II is present, then Field_I is required.

For example:

  • Record1 has the conditional validator C0102
  • Field_II - Nth field extractor, position 1
  • Field_I - Nth field extractor, position 2

This indicates that if Field_I is present, then Field_II also must be present. If you switch the position of these fields in the record, you get the following values:

  • Record1 - conditional validator C0102
  • Field_II - Nth field extractor, position 2
  • Field_I - Nth field extractor, position 1

This indicates that if Field_II is present, then Field_I also must be present.

In the document string D5 010 020 D5 030 040 050, the character D5 represents the code, and the numerals 010, 020, 030, 040, and 050 represents the fields of a UN/EDIFACT conditional validator:

The record definition has five fields defined. Each with an Nth Field extractor, the first being field_I, the second field_II and so on. Both of these validators indicate that if Field_I is present, Field_II is required. If Field_III is present, Field_IV and Field_V are required; however, if Field_IV and Field_V are present, Field_III need not be present.

The following table indicates the codes for ANSI X12 and UN/EDIFACT documents based on the values in the preceding illustrations:

ANSI X12 rule name (and code) UN/EDIFACT rule name (and code) Description
Required (R) One or more (D3) At least one of the specified fields must be present.

ANSI X12 Example: R030405

UN/EDIFACT Example: D3(030,040,050)

Conditional (C) If first, then all (D5) If a specified field is present, all of the fields specified in a dependent set of fields also must be present. If a dependent field is present, the first specified field need not be present.

ANSI X12 Example: C030405

If you specify a field value of 00, the extra zeros are trimmed when the value is saved. For example, if you type C030400, the fields: 03, 04, and 00 are interpreted in pairs. 00 is trimmed as applying the conditional validator does not alter it.

UN/EDIFACT Example: D5(030,040,050)

Exclusion (E) One or none (D4) At most, only one of the specified fields can be present.

ANSI X12 Example: E030405

UN/EDIFACT Example: D4(030,040,050)

List Conditional (L) If first, then at least one (D6) If a specified field is present, at least one of the fields specified in a dependent set of fields also must be present. If a dependent field is present, the first specified field need not be present.

ANSI X12 Example: L030405

UN/EDIFACT Example: D6(030,040,050)

Paired (P) All or none (D2) All of the specified fields must be present or absent.

ANSI X12 Example: P030405

UN/EDIFACT Example: D2(010,020)

N/A One and only one (D1) Exactly one field may be present.

UN/EDIFACT Example: D1(030,040,050)

NA If first, then none (D7) If the first field is present, all others cannot be included.

UN/EDIFACT Example: D7(030,040,050)

Code list validators

Code list validators are used to validate field lengths or code lists when webMethods B2B processes a document. When you select the code list validator for a field or a record, webMethods B2B appends /code in the xPath query for the attributes you want to extract. For example, the /ST/ST01/code. Modifying a validator for a field or a record from or to a code list validator impacts the existing attribute queries and these queries require updates accordingly.