react-jsonschema验证以检查是否至少选中了一个复选框不起作用

问题描述

下面是具有三个复选框的formSchema。如果未选中任何复选框并输入了提交,则应该显示一条验证消息,指出必须至少选中一个不起作用的复选框。

“ formSchema”:{ “ title”:“必须至少选中一个复选框”, “ type”:“ object”, “必填”:[

        "question3"
      ],"properties" : {

    "question3" : {
      "title" : "question1","description" : "","type" : "object","required" : [
              "question3Options"
            ],"properties" : {
        "question3Options" : {
          "title" : "","properties" : {
            "examone" : {
              "title" : "","properties" : {
                "op1" : {
                  "title" : "EXAMONE","type" : "boolean"
                }
              },"dependencies" : {
                "op1" : {
                  "oneOf" : [
                    {
                      "required": [
                        "question3Op1Reason"
                      ],"properties": {
                        "op1": {
                          "enum": [
                            true
                          ]
                        },"question3Op1Reason": {
                          "type": "string","title": "Explain:"
                        }
                      }
                    }
                  ]
                }
              }
            },"examtwo" : {
              "title" : "","properties" : {
                "op2" : {
                  "title" : "EXAMTWO","dependencies" : {
                "op2" : {
                  "oneOf" : [
                    {
                      "required": [
                        "question3Op2Reason"
                      ],"properties": {
                        "op2": {
                          "enum": [
                            true
                          ]
                        },"question3Op2Reason": {
                          "type": "string","title": "Explain :"
                        }
                      }
                    }
                  ]
                }
              }
            },"examthree" : {
              "title" : "","properties" : {
                "op3" : {
                  "title" : "EXAMTHREE","dependencies" : {
                "op3" : {
                  "oneOf" : [
                    {
                      "required": [
                        "question3Op3Reason"
                      ],"properties": {
                        "op3": {
                          "enum": [
                            true
                          ]
                        },"question3Op3Reason": {
                          "type": "string","title": "Explain:"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}


=====================================

下面是uiSchema

"uiSchema" : {
  "question3" : {
      "question3Options" : {
          "pdmqi" : {
              "question3Op1Reason" : {
                  "ui:widget" : "textarea","ui:options" : {
                      "rows" : 5.0
                  }
              }
          },"ecd" : {
              "question3Op2Reason" : {
                  "ui:widget" : "textarea","health" : {
              "question3Op3Reason" : {
                  "ui:widget" : "textarea","ui:options" : {
                      "rows" : 5.0
                  }
              }
          }
      }
  },}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)