Skip to content

Commit 1dd9fc1

Browse files
yT0n1barmac
authored andcommitted
fix: Ensure that formId and externalResource cannot be used together
related to camunda/camunda-modeler#5073
1 parent 2e12c52 commit 1dd9fc1

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed

packages/zeebe-element-templates-json-schema/src/defs/template.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,70 @@
598598
}
599599
]
600600
}
601+
},
602+
{
603+
"if": {
604+
"properties": {
605+
"properties": {
606+
"contains": {
607+
"properties": {
608+
"binding": {
609+
"properties": {
610+
"property": {
611+
"const": "formId"
612+
},
613+
"type": {
614+
"const": "zeebe:formDefinition"
615+
}
616+
},
617+
"required": [
618+
"property",
619+
"type"
620+
]
621+
}
622+
},
623+
"required": [
624+
"binding"
625+
]
626+
}
627+
}
628+
},
629+
"required": [
630+
"properties"
631+
]
632+
},
633+
"then": {
634+
"properties": {
635+
"properties": {
636+
"not": {
637+
"contains": {
638+
"properties": {
639+
"binding": {
640+
"properties": {
641+
"type": {
642+
"const": "zeebe:formDefinition"
643+
},
644+
"property": {
645+
"const": "externalReference"
646+
}
647+
},
648+
"required": [
649+
"property",
650+
"type"
651+
]
652+
}
653+
},
654+
"required": [
655+
"binding"
656+
]
657+
}
658+
}
659+
}
660+
},
661+
"required": [
662+
"properties"
663+
]
664+
}
601665
}
602666
]
603667
}

packages/zeebe-element-templates-json-schema/src/error-messages.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,19 @@
315315
"then"
316316
],
317317
"errorMessage": "Property \"resultVariable\" cannot be a Feel expression"
318+
},
319+
{
320+
"path": [
321+
"definitions",
322+
"template",
323+
"allOf",
324+
1,
325+
"allOf",
326+
7,
327+
"then",
328+
"properties",
329+
"properties"
330+
],
331+
"errorMessage": "\"formId\" and \"externalReference\" cannot be used together"
318332
}
319333
]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
export const template = {
2+
'$schema': 'https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json',
3+
'name': 'Form Definition with external reference',
4+
'id': 'formDefinitionWithExternalReference',
5+
'appliesTo': [
6+
'bpmn:Task'
7+
],
8+
'elementType': {
9+
'value': 'bpmn:UserTask'
10+
},
11+
'properties': [
12+
{
13+
'type': 'Hidden',
14+
'binding': {
15+
'type': 'zeebe:userTask',
16+
}
17+
},
18+
{
19+
'type': 'Hidden',
20+
'value': 'aReference',
21+
'binding': {
22+
'type': 'zeebe:formDefinition',
23+
'property': 'externalReference'
24+
}
25+
},
26+
{
27+
'type': 'Hidden',
28+
'value': 'anId',
29+
'binding': {
30+
'type': 'zeebe:formDefinition',
31+
'property': 'formId'
32+
}
33+
}
34+
]
35+
};
36+
37+
export const errors = [
38+
{
39+
keyword: 'errorMessage',
40+
dataPath: '/properties',
41+
schemaPath: '#/allOf/1/allOf/7/then/properties/properties/errorMessage',
42+
params: {
43+
errors: [
44+
{
45+
keyword: 'not',
46+
dataPath: '/properties',
47+
schemaPath: '#/allOf/1/allOf/7/then/properties/properties/not',
48+
params: {},
49+
message: 'should NOT be valid',
50+
emUsed: true
51+
}
52+
]
53+
},
54+
message: '"formId" and "externalReference" cannot be used together'
55+
},
56+
{
57+
keyword: 'if',
58+
dataPath: '',
59+
schemaPath: '#/allOf/1/allOf/7/if',
60+
params: {
61+
failingKeyword: 'then'
62+
},
63+
message: 'should match "then" schema'
64+
},
65+
{
66+
keyword: 'type',
67+
dataPath: '',
68+
schemaPath: '#/oneOf/1/type',
69+
params: {
70+
type: 'array'
71+
},
72+
message: 'should be array'
73+
},
74+
{
75+
keyword: 'oneOf',
76+
dataPath: '',
77+
schemaPath: '#/oneOf',
78+
params: {
79+
passingSchemas: null
80+
},
81+
message: 'should match exactly one schema in oneOf'
82+
}
83+
];

packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ describe('validation', function() {
498498

499499
it('form-definition-invalid-element-type');
500500

501+
it('form-definition-invalid-external-reference-and-formId');
502+
501503
it('form-definition-invalid-formId-feel');
502504

503505
it('form-definition-missing-zeebe-user-task');

0 commit comments

Comments
 (0)