Structure Group

This element helps to group multiple structures within the same / different resources of the same product and version.

Possible Locations

Child Elements

Attributes


Name Type Description
name String Name of the structure group. If you add a name here, then it is mandatory to add names to all the child structures.
type
required
String The quantifier based on which ZEST should pick the <structure> for a case. The possible values are one-of, any-of, all-of, array-of
Note:

The attribute name is preferred, when structure group is a child element of <content>.

Quantifier Expressions:

  • One-of - It validates the structures against only one structure from a group of structures.
  • Any-of - Atleast any one or more than one of the structure can match your case from a group of structures.
  • All-of - All the structures in a structure group should match your case.
  • Array-of - It will help you to retain the order of the structures given in the structure group and it can be repeated multiple times.

Example

Let us see how this structure group works for the types one-of, any-of, all-of and array-of.

For the ease of understanding, we’ll have the below structure group,

    
copy
<structure-group name="Example" type="one-of/all-of/any-of/array-of"> <structure name="A"> <property name="field1" type="string" /> <property name="field2" type="string" /> </structure> <structure name="B"> <property name="field3" type="string" /> <property name="field4" type="string" /> </structure> <structure name="C"> <property name="field5" type="string" /> <property name="field6" type="string" /> </structure> </structure-group>

To keep it simple, we have not included any <extra-property> in the structures. Yet, any-of and all-of types demand extra properties to exhibit their full potential. So, consider that by default we have the below extra-property configured for all the three structures.

    
copy

one-of

In one-of, the value must match any one of the structures from the structure group.

  • For a structure group under a map <property>, if the value matches more than one <structure>, error will be thrown.
  • For the structure group under a collection property, each of the values can match any one of the below structures.

The set of structures one-of builds for validation are as follows,

    
copy
<structure name="A"> <property name="field1" type="string" /> <property name="field2" type="string" /> </structure> <structure name="B"> <property name="field3" type="string" /> <property name="field4" type="string" /> </structure> <structure name="C"> <property name="field5" type="string" /> <property name="field6" type="string" /> </structure>

all-of

In this type, the value has to match all the structures, i.e. ZEST will build a new <structure> merging these three and expects the value to match it. All the three structures has to allow <extra-property> in order to use this type.

Following is the merged structure that ZEST uses for validation,

    
copy
<structure name="ABC"> <property name="field1" type="string"/> <property name="field2" type="string"/> <property name="field3" type="string"/> <property name="field4" type="string"/> <property name="field5" type="string"/> <property name="field6" type="string"/> </structure>

any-of

In any-of, the value has to match one or more structures. All the structures should accept <extra-property> to accept combination of these structures.

So, the set of structures that any-of will produce for validation are as follows:

    
copy
<structure name="A"> <property name="field1" type="string"/> <property name="field2" type="string"/> </structure> <structure name="B"> <property name="field3" type="string"/> <property name="field4" type="string"/> </structure> <structure name="C"> <property name="field5" type="string"/> <property name="field6" type="string"/> </structure> <!-- following are the combinations of the three structures --> <structure name="AB"> <property name="field1" type="string"/> <property name="field2" type="string"/> <property name="field3" type="string"/> <property name="field4" type="string"/> </structure> <structure name="AC"> <property name="field1" type="string"/> <property name="field2" type="string"/> <property name="field5" type="string"/> <property name="field6" type="string"/> </structure> <structure name="BC"> <property name="field3" type="string"/> <property name="field4" type="string"/> <property name="field5" type="string"/> <property name="field6" type="string"/> </structure> <structure name="ABC"> <property name="field1" type="string"/> <property name="field2" type="string"/> <property name="field3" type="string"/> <property name="field4" type="string"/> <property name="field5" type="string"/> <property name="field6" type="string"/> </structure>

The value has to match any of the above structures. If the <structure> does not accepts extra-property, then any-of will not produce any combinations and will behave as same as one-of.

array-of

This array-of structure group is applicable only to the <property> that have collections as its data type. This type functions similar to one-of and not produces any combinations. But, the list of values has to match the structures in the same order as given in the structure group. Whereas in one-of, the values can either match the same <structure> as the preceding value or a different structure which is not next in the order.

Another major trait of this type is, it enables you to repeat the structures as many times as you want, yet, retaining the same order. i.e., the structures will start again in the same order to fill the remaining number of times.

Let us say the length is given as 5 in the property. So, all the five values taken for validation should match the structures in the following order,

    
copy
<structure name="A"> <property name="field1" type="string" /> <property name="field2" type="string" /> </structure> <structure name="B"> <property name="field3" type="string" /> <property name="field4" type="string" /> </structure> <structure name="C"> <property name="field5" type="string" /> <property name="field6" type="string" /> </structure> <structure name="A"> <property name="field1" type="string" /> <property name="field2" type="string" /> </structure> <structure name="B"> <property name="field3" type="string" /> <property name="field4" type="string" /> </structure>

Here, in the 4th index, the structure starts again from ‘A’ to fill the remaining 2 counts.

Last Updated 2025-05-30 16:54:59 +0530 +0530