我想验证温度和冷却因子的值是否小于零,但是我不确定是否使用最小值:例如,-10,-20是否正确使用。
对于温度,冷却系数和风速的实际最大值也是如此。
什么是正确使用?
非常感谢。
JsonSchema的用法如下:
"type": "object",
"properties": {
"weather": {
"type": "array",
"items": {
"type": "object",
"properties": {
"windSpeed": {
"type": "number",
"minimum": 0.00
},
"cityName": {
"type": "string"
},
"currentConditions": {
"type": "string",
"enum": [ "Cloud", "Snow", "Sun", "Hail", "Rain", "Sleet", "Heavy Rain"]
},
"temperature": {
"type": "number",
"minimum": 0.00
},
"windDirection": {
"type": "string",
"enum": ["Northerly", "North easterly", "Easterly", "South easterly", "Southerly", "South westerly", "Westerly", "North westerly"]
},
"windChillFactor": {
"type": "number",
"minimum": 0.00
}
},
"required": ["cityId", "cityName", "currentConditions", "temperature", "windSpeed", "windDirection", "windChillFactor"]
}
}
}
}
通常,当不确定这类事情时,我建议采用以下两种方法之一:
multipleOf
描述为仅允许使用正值,但对于minimum
/ maximum
,任何数值(包括负数)都应该是正确的(即使为简单起见,示例仅使用正值)。此外,您的架构看起来还不错。您可能想将cityId
包括在weather.items.properties
中(而不仅仅是在weather.items.required
中)以指示其类型。