Validations within Modelio to use with jhipster-uml

363 Views Asked by At

I'm using Modelio to create an xmi to use with jhipster-uml.
Is there a way to add validation rules to the attributes in Modelio so that when the xmi is imported, the validation rules(required, minimum length, maximum length, etc.) would be in the entities?

For example, the json generated currently looks like this:

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

but I want to make it look like this (this was generated using 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

There are 1 best solutions below

0
On BEST ANSWER

I got it to work. Here are the steps I took:

  1. Go to Common->Constraint and make a constraint from the attribute to an open space.

  2. Set the name to validation rule (e.g. "minlength") and the body to the validation value (e.g. "4").

  3. When exporting as XMI, make sure to Export with compatibility of "OMG UML2.4.1"