JSON模式在运行时基于列表验证输入 [英] JSON schema validate input based on list at runtime

查看:57
本文介绍了JSON模式在运行时基于列表验证输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以定义一个架构以在运行时基于值列表执行验证.示例:

I'd like to know if I can define a schema to perform validation based on list of values at runtime. Example:

people:
- joe
- fred
- anna

bestfriend: ike

我想定义一个架构,其中bestfriend 的值限制为people 的值.该模式将people定义为字符串数组.

I'd like to define a schema where the value of bestfriend is limited to the values of people . The schema defines people as array of string.

它看起来有点像如何针对运行时JSON对象引用进行验证?答案已过期的地方.

It looks a little like How to validate against runtime JSON object reference? where the answer is outdated.

推荐答案

不能,但是您可以在运行时生成包含这些值的新架构,然后对其进行评估.

No you cannot, but you could generate a new schema at runtime containing those values and then evaluate against that.

这篇关于JSON模式在运行时基于列表验证输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆