Skip to content

Config Validator

Validators ensure that the given value fulfills the specified condition.

Validators can be either used on their own or in a possibly nested Validator Group structure.

Validators are used to validate configuration Data Types.

Model

Validator can be used as a plain Validator or as Validator Group. They are interchangeable.

Validator

attribute supported data types description
equal
[mixed]
bool, enum, hex, ipv4, ipv6, mac6, number, password, string An array holding the values of which one must be matched.
notEqual
[mixed]
bool, enum, hex, ipv4, ipv6, mac6, number, password, string An array holding the values of which none must be matched.
min
number|hex
number, hex The lowest valid value
max
number|hex
number, hex The highest valid value
greaterOrEqual
string|Reference Compare
number, hex, ipv4 Reference Compare object or the value must be greater then or equal to the value held in the field identified by the supplied SEID. This validator should always be used in opposition with lessOrEqual.
lessOrEqual
string|Reference Compare
number, hex, ipv4 Reference Compare object or the value must be less then or equal to the value held in the field identified by the supplied SEID. This validator should always be used in opposition with greaterOrEqual.
minLength
unsigned int
string The minimal valid length of the string
maxLength
unsigned int
string The maximal valid length of the string
regexp
string
string The regular expression the value must match
maxRows
unsigned int
table The maximal allowed number of rows.
minRows
unsigned int
table The minimal allowed number of rows.
unique
[string]
table Checks that the value is unique within the specified columns. Uniqueness is checked for each column independently, multi-column constraints are not supported.

Reference Compare

For validating with lessOrEqual or greaterOrEqual when a minimal difference between values is required, the validator can be defined as an object.

attribute description
referenced_seid*
seid
The field against which to compare.
offset*
number|hex
The minimal required difference between the numbers.

Example

The given number must be 20 or greater.

{ "min": 20 }

Validator Group

attribute description
operator*
'&&'|'||'
Defines the logical relationship between groups in the validators array
validators*
[Validator]
The validator array

Example

The given number must be at least 5 and at most 10 or be 20 or larger.

{
  "operator": "||",
  "validators": [
    {
      "operator": "&&",
      "validators": [
        { "min": 5 },
        { "max": 10 }
      ]
    },
    { "min": 20 },
  ]
}