Extra Property
An extra property behaves the same as a usual <property> except for the name which has to match the regex pattern provided in the name-regex attribute.
Possible Location
Attributes
Name | Type | Description |
---|---|---|
name-regex required |
string | The regex pattern to which the name of the extra-property should match. |
- The attribute name-regex is mandatory only if you add more than one extra-property to a <structure>. When there is only one extra-property in a structure and its name-regex is not specified, the default regex will be “.+”.
- The name-regex attribute should be unique when you add more than one extra-property to a structure.
- Except for the name attribute, extra-property can have all the attributes and child elements of a property.
- Other than the name-regex attribute, all the child elements and attributes are optional for the extra-property.
Elemental Behavior:
An extra-property can accept as many key-value pairs as it match the configured name-regex attribute. If you want to control the number of extra properties, utilize the length attribute in the property of the corresponding structure.
Example
Let us take a <structure> from the trips resource, in which there are a set of predefined features (<property>) of the trip. Addedly, the structure supports 2 custom properties created over the predefined ones. This support is for the users to add their personal requirements for the trip. The name of the custom properties cannot be declared as it may vary depending upon users and their needs.
To configure the custom properties, use the extra-property as follows,
copy<structure> <property type="map" length="5"> <structure> <property name="trip_name" type="string" /> <property name="travelers" type="collections"> <structure> <property name="string" /> </structure> </property> <property name="destination" type="string" /> <extra-property name-regex="^custom-[a-z]+$" type="object" /> </structure> </property> </structure>
According to this sample, the name of the custom keys should match the regex pattern i.e., all the custom key names will have the prefix custom. This will help in easy identification of the custom properties.
Last Updated 2025-05-30 16:54:59 +0530 +0530
Yes
No
Send your feedback to us