Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate group ids for existance #40

Open
pinussilvestrus opened this issue Jan 31, 2022 · 1 comment
Open

Validate group ids for existance #40

pinussilvestrus opened this issue Jan 31, 2022 · 1 comment
Labels
backlog Queued in backlog enhancement New feature or request spring cleaning Could be cleaned up one day

Comments

@pinussilvestrus
Copy link
Contributor

What should we do?

The validator should fail if a property defines a group that is not defined in the upper groups array.

The following template should me markets as invalid

{
  'name': 'Grouping',
  'id': 'example.com.missingGroupId',
  'appliesTo': [
    'bpmn:ServiceTask'
  ],
  'properties': [
    {
      'label': 'input 1',
      'type': 'String',
      'group': 'two',
      'binding': {
        'type': 'camunda:inputParameter',
        'name': 'input1'
      }
    }
  ],
  'groups': [
    {
      'id': 'one',
      'label': 'Group one'
    }
  ]
}

Why should we do it?

Make sure we don't use non-existing groups.

@pinussilvestrus pinussilvestrus added enhancement New feature or request backlog Queued in backlog labels Jan 31, 2022
@pinussilvestrus
Copy link
Contributor Author

pinussilvestrus commented Jan 31, 2022

That might be possible via if-then rule, although it seems to be hard to dynamically test values against a parent array property. Sketch via https://github.com/camunda/element-templates-json-schema/tree/group-id-rule

"if": {
  "properties": {
    "group": {
      "pattern": "^(?!\/s*$).+/"
    }
  },
  "required": [
    "group"
  ]
},
"then": {
  "#/groups": {
    "contains": {
      "type": "object",
      "properties": {
        "id": {
          "const": "${0/group}"
        }
      }
    }
  },
  "errorMessage": "invalid group id ${0/group}, not defined in groups"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog enhancement New feature or request spring cleaning Could be cleaned up one day
Projects
None yet
Development

No branches or pull requests

1 participant