如何在JSON模式中为一个字段定义不同的类型?
例如,需要验证字段等级 - 而不是空白字符串(可以转换为整数)或1000和1000之间的整数
For example, need to validate field GRADE - not blank string (which can be converted to integer) or integer between 1 and 1000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最基本的定义是:
请查看
模式
关键字,如下所述: https://json-schema.org/understanding-json-schema/reference/reference/string.html#id6您可以定义一个确切的正则表达式年级领域的要求。
The most basic definition would be:
Take a look at the
pattern
keyword as described in detail here: https://json-schema.org/understanding-json-schema/reference/string.html#id6You can define a regular expression that meets your exact requirements for the GRADE field.