Giter VIP home page Giter VIP logo

Comments (1)

daniel-dx avatar daniel-dx commented on May 12, 2024

当为对象时,如果对象是个空对象,会正确触发必填校验
这里比较特殊是,如果下拉框选择了值,那对象其实是有值的,而你的场景是想填了文本框才算校验通过,所以可以结合customRule来实现

注意: @ncform/ncform-theme-elementui 需要升级到0.1.14版本

示例代码如下:
打开playground
复制以下配置查看效果

{
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "ui": {
        "widget": "input",
        "widgetConfig": {
          "modelField": "name",
          "compound": {
            "prependSelect": {
              "itemLabelField": "label",
              "itemValueField": "value",
              "enumSource": [
                {
                  "value": 1,
                  "label": "男"
                },
                {
                  "value": 2,
                  "label": "女"
                }
              ],
              "modelField": "gender"
            }
          }
        }
      },
      "rules": {
        "required": true,
        "customRule": [
          {
            "script": "dx: {{$root.user}}.name",
            "errMsg": "名字必填"
          }
        ]
      }
    }
  }
}

from ncform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.