Array
An array of items of the same type
Specification
spec
Describes the data structure of array items.
Parameters inside spec use the syntax of the regular parameters.
Available types:
object
The output is an array of primitive types. If the object contains a name, it will be ignored.
array
The output is a complex array of Objects.
{
"name": "tags",
"spec": {
"type": "text",
"label": "Tag"
},
"type": "array",
"label": "Tags"
}{
"name": "contacts",
"spec": [
{
"name": "email",
"type": "email",
"label": "Email"
},
{
"name": "name",
"type": "text",
"label": "Name"
}
],
"type": "array",
"label": "Contacts"validate
Type:
ObjectCollection of validation directives.
Available parameters:
maxItems
number
Specifies the maximum length that an array parameter can have.
minItems
number
Specifies the minimum length that an array parameter can have.
enum
array
Array of allowed values in the array.



[
{
"name": "members",
"type": "array",
"label": "Members",
"validate": {
"minItems": 1,
"maxItems": 4,
"enum": [
"member1",
"member2",
"member3",
"member4"
]
}
}
]mode
Type:
StringAllowed values are
editandchoose.
When the array is editable , you can set the default state by using mode.

[
{
"name": "choose",
"type": "array",
"label": "Choosable array",
"mode": "choose"
},
{
"name": "edit",
"type": "array",
"label": "Editable array",
"mode": "edit"
}
]labels
Available parameters:
add
string
Default: Add item. The text is displayed on the adding button.
Examples
Primitive array
The primitive array is an array of simple variables, like numbers or strings.

[
{
"name": "tags",
"spec": {
"type": "text",
"label": "Tag"
},
"type": "array",
"label": "Tags"
}
]["old", "new"]Complex array
The complex array is an array of complex objects - collections.

[
{
"name": "contacts",
"spec": [
{
"name": "email",
"type": "email",
"label": "Email"
},
{
"name": "name",
"type": "text",
"label": "Name"
}
],
"type": "array",
"label": "Contacts"
}
][
{
"name": "John Doe",
"email": "[email protected]"
},
{
"name": "Foo Bar",
"email": "[email protected]"
}
]Complex array with labeled collections

[
{
"name": "contacts",
"spec": {
"type": "collection",
"label": "Contact",
"spec": [
{
"name": "email",
"type": "email",
"label": "Email"
},
{
"name": "name",
"type": "text",
"label": "Name"
}
]
},
"type": "array",
"label": "Contacts"
}
][
{
"name": "John Doe",
"email": "[email protected]"
},
{
"name": "Foo Bar",
"email": "[email protected]"
}
]Amount of items
Use the validate object to set minItems and maxItems to control the minimum and/or maximum amount of items in the array.

[
{
"name": "members",
"type": "array",
"label": "Members",
"validate": {
"minItems": 1,
"maxItems": 4
}
}
]Custom labels
Customize the button labels using the labels object.

[
{
"name": "labels",
"type": "array",
"label": "Customized array",
"labels": {
"add": "Add an item to my array"
}
}
]Last updated

