有没有办法在 JSON 模式表单中设置最小日期?使用 min 不起作用,这是一个示例:
{
"title": "Date picker",
"type": "object",
"properties": {
"native": {
"title": "Title",
"description": "description",
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date",
"default": "2023-10-26",
"min": "2023-10-26"
}
}
}
}
}
min
不是 json 模式关键字。 minimum
是,但它只适用于数字,不适用于字符串。
在当前发布的 JSON Schema 版本中,您可以使用正则表达式实现最小检查的近似值:
description: at or later than 2023-10-26, up to 2099-12-31
type: string
format: date
anyOf:
- pattern: ^2023-10-2[6-9]
- pattern: ^2023-1[12]
- pattern: ^202[4-9]
- pattern: ^20[3-9]