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. |
minnumber|hex |
number, hex |
The lowest valid value |
maxnumber|hex |
number, hex |
The highest valid value |
greaterOrEqualstring|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. |
lessOrEqualstring|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. |
minLengthunsigned int |
string |
The minimal valid length of the string |
maxLengthunsigned int |
string |
The maximal valid length of the string |
regexpstring |
string |
The regular expression the value must match |
maxRowsunsigned int |
table |
The maximal allowed number of rows. |
minRowsunsigned int |
table |
The minimal allowed number of rows. |
unique[string|[string]] |
table |
Checks that the value is unique within the specified columns. Uniqueness is checked for each item independently. An item is either a column name or an array of column names (a composite key), in which case the combination of their values must be unique. |
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 combination of values in the columns address and port must be unique
and the values in the column name must be unique on their own.
{ "unique": [["address", "port"], "name"] }
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 },
]
}