Modelio中的验证与jhipster-uml一起使用

时间:2016-01-18 19:22:44

标签: jhipster modelio

我正在使用Modelio来创建一个与jhipster-uml一起使用的xmi 有没有办法将验证规则添加到Modelio中的属性,以便在导入xmi时,验证规则(必需,最小长度,最大长度等)将在实体中?

例如,目前生成的json如下所示:

{
  "relationships": [],
  "fields": [
    {
      "fieldId": 1,
      "fieldName": "name",
      "fieldType": "String"
    },
  ],
  "changelogDate": "20160118185613",
  "dto": "no",
  "pagination": "no"
}

但我想让它看起来像这样(这是使用yo jhipster:entity生成的):

{
    "relationships": [],
    "fields": [
        {
            "fieldId": 1,
            "fieldName": "name",
            "fieldType": "String",
            "fieldValidateRules": [
                "required",
                "minlength",
                "maxlength",
                "pattern"
            ],
            "fieldValidateRulesMinlength": "10",
            "fieldValidateRulesMaxlength": "100",
            "fieldValidateRulesPattern": "^[a-zA-Z0-9]*$",
            "fieldValidateRulesPatternJava": "^[a-zA-Z0-9]*$"
        },
    ],
    "changelogDate": "20160118184133",
    "dto": "no",
    "service": "no",
    "pagination": "no"
}

1 个答案:

答案 0 :(得分:0)

我得到了它的工作。以下是我采取的步骤:

  1. 转到Common-> Constraint并从属性约束到开放空间。

  2. 将名称设置为验证规则(例如“minlength”),将正文设置为验证值(例如“4”)。

  3. 导出为XMI时,请确保导出兼容性为“OMG UML2.4.1”