Concepts
JSON Schema
Eventvisor makes use of a subset of the JSON Schema specification when defining attribute and event schemas.
Supported types are listed below:
string#
For simple strings (text values):
type: string
enum#
You can specify a list of allowed values for a string:
type: stringenum: - foo - bar
maxLength#
You can specify the maximum length for a string:
type: stringmaxLength: 100
minLength#
You can specify the minimum length for a string:
type: stringminLength: 0
pattern#
You can specify a regular expression for a string:
type: stringpattern: ^[a-z]+$
boolean#
For boolean (true/false) values:
type: boolean
number#
For numeric values (integer or float):
type: number
maximum#
You can specify the maximum value for a number:
type: numbermaximum: 100
minimum#
You can specify the minimum value for a number:
type: numberminimum: 0
integer#
For whole numbers only:
type: integer
Similar to number
, you can also specify the maximum and minimum values for an integer.
object#
For objects (key-value pairs):
type: objectproperties: firstProperty: type: string secondProperty: type: numberrequired: - firstProperty
Nested objects#
You can also define nested objects:
type: objectproperties: firstProperty: type: string nested: type: object properties: foo: type: string bar: type: string required: - foo - barrequired: - firstProperty
array#
For arrays:
type: arrayitems: type: string
When inside an object:
type: objectproperties: arrayProperty: type: array items: type: stringrequired: - arrayProperty
maxItems#
You can specify the maximum number of items for an array:
type: arraymaxItems: 100
minItems#
You can specify the minimum number of items for an array:
type: arrayminItems: 0
uniqueItems#
You can specify if the items in the array should be unique:
type: arrayuniqueItems: true
Common properties#
You can make use of the following properties for all types above:
const#
You can specify a constant value:
type: stringconst: "foo"
default#
You can specify a default value:
type: stringdefault: "default value"