json模式以确保字符串与数组的任何元素都不匹配

问题描述 投票:1回答:1
{
  "title":"x",
  "type:"string",
  "doesNotMatch":["element1","element2"]
}

是否存在JSON模式,以确保JSON数据与element1和element2不匹配。

  • {"x":element1}无效
  • {"x":"daf"}有效提供“daf”不等于element1和element2
jsonschema json-schema-validator
1个回答
2
投票

not enum应该帮助你:

{
  "title":"x",
  "type:"string",
  "not": {"enum":["element1","element2"]}
}
© www.soinside.com 2019 - 2024. All rights reserved.