我有一个简单的JSON模式,看起来像
{
"cols": {
"type": "array",
"items": {
"type": "string",
"enum": [
"id",
"name",
"age",
"affiliation",
""
]
},
"additionalProperties": false
}
}
我希望enum
是上面规定的值+一个装饰,这样以下任何一个都可以进行
"enum" = [
"id",
"lower(name)",
"average(age)",
"distinct(affiliation)",
""
]
换句话说,对于cols
cols=id
有效,但不允许在id
周围进行进一步装饰cols=name
和cols=lower(name)
将是有效的cols=age
和cols=average(age)
将是有效的cols=affiliation
和cols=distinct(affiliation)
将有效cols=''
空字符串将有效
将装饰指定为模式非常好,这样它们就不区分大小写了。例如,cols=lower(name)
和cols=LOWER(name)
都可以
您可以将enum
中的枚举列表更改为模式列表:
"items": [
"type": "string",
"anyOf": [
{ "pattern": "^colsb...the rest of your pattern here...$" },
{ etc... }
]
]