Angular 架构表单 + 突出显示表单加载时出错的字段

Angular schema form + highlight fields with errors on form load

我正在使用 angular 架构形式。我遇到的问题是,当我尝试加载表单时,缺少一些必需的属性!该表格不指示缺少的属性。但是,当我单击该特定字段并编辑某些内容然后将其删除时,它确实会为我突出显示该字段。我希望这也发生在初始加载时。寻找指点。谢谢

您需要在表单配置架构中使用 required 属性:

//..other fields
"required": [
    "name",
    "email",
    "comment"
  ]

检查 demo here,它也有必填字段:

{
  "type": "object",
  "title": "Comment",
  "properties": {
    "name":  {
      "title": "Name",
      "type": "string"
    },//here validation details
    "email":  {
      "title": "Email",
      "type": "string",
      "pattern": "^\S+@\S+$",
      "description": "Email will be used for evil."
    },
    "comment": {
      "title": "Comment",
      "type": "string",
      "maxLength": 20,
      "validationMessage": "Don't be greedy!"
    }
  },//here naming fields required
  "required": ["name","email","comment"]
}

属性是validateOnRender: true

需要添加到表格的global options object