diff --git a/packages/zeebe-element-templates-json-schema/CHANGELOG.md b/packages/zeebe-element-templates-json-schema/CHANGELOG.md index ec17e10..5dcf895 100644 --- a/packages/zeebe-element-templates-json-schema/CHANGELOG.md +++ b/packages/zeebe-element-templates-json-schema/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to [@camunda/zeebe-element-templates-json-schema](https://gi ___Note:__ Yet to be released changes appear here._ +## 0.20.0 + +* `FEAT`: support `placeholder` property + ## 0.19.2 * `FIX`: allow number values for `Number` properties ([#138](https://github.com/camunda/element-templates-json-schema/issues/138)) diff --git a/packages/zeebe-element-templates-json-schema/src/defs/properties.json b/packages/zeebe-element-templates-json-schema/src/defs/properties.json index 5aae5cb..eee7f6c 100644 --- a/packages/zeebe-element-templates-json-schema/src/defs/properties.json +++ b/packages/zeebe-element-templates-json-schema/src/defs/properties.json @@ -273,6 +273,47 @@ } } } + }, + { + "if": { + "oneOf": [ + { + "properties": { + "type": { + "enum": [ + "String", + "Text", + "Number" + ] + } + }, + "required": [ + "type" + ] + }, + { + "not": { + "required": [ + "type" + ] + } + } + ] + }, + "then": { + "properties": { + "placeholder": { + "type": "string" + } + } + }, + "else": { + "not": { + "required": [ + "placeholder" + ] + } + } } ], "properties": { diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-property.js b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-property.js new file mode 100644 index 0000000..c987097 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-property.js @@ -0,0 +1,49 @@ +export const template = { + name: 'Tooltip', + id: 'example.com.tooltip', + appliesTo: [ + 'bpmn:ServiceTask' + ], + properties: [ + { + label: 'Input with placeholder', + type: 'Boolean', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: 'Invalid input type' + } + ] +}; + +export const errors = [ + { + 'dataPath': '/properties/0', + 'keyword': 'not', + 'message': 'should NOT be valid', + 'params': {}, + 'schemaPath': '#/allOf/1/items/allOf/10/else/not', + }, + { + 'dataPath': '/properties/0', + 'keyword': 'if', + 'message': 'should match "else" schema', + params: { failingKeyword: 'else' }, + schemaPath: '#/allOf/1/items/allOf/10/if' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-type.js b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-type.js new file mode 100644 index 0000000..62bdc68 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder-invalid-type.js @@ -0,0 +1,49 @@ +export const template = { + name: 'Tooltip', + id: 'example.com.tooltip', + appliesTo: [ + 'bpmn:ServiceTask' + ], + properties: [ + { + label: 'Input with placeholder', + type: 'String', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: [ 'invalid placeholder type' ] + } + ] +}; + +export const errors = [ + { + keyword: 'type', + dataPath: '/properties/0/placeholder', + schemaPath: '#/allOf/1/items/allOf/10/then/properties/placeholder/type', + params: { type: 'string' }, + message: 'should be string' + }, + { + dataPath: '/properties/0', + keyword: 'if', + message: 'should match "then" schema', + params: { failingKeyword: 'then' }, + schemaPath: '#/allOf/1/items/allOf/10/if' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder.js b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder.js new file mode 100644 index 0000000..7cd18a5 --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/placeholder.js @@ -0,0 +1,46 @@ +export const template = { + name: 'Tooltip', + id: 'example.com.tooltip', + appliesTo: [ + 'bpmn:ServiceTask' + ], + properties: [ + { + label: 'Input with placeholder', + type: 'String', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: 'This field has a placeholder' + }, + { + label: 'Input with placeholder', + type: 'Text', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: 'This field has a placeholder' + }, + { + label: 'Input with placeholder', + type: 'Number', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: 'This field has a placeholder' + }, + { + label: 'Input with placeholder', + binding: { + type: 'property', + name: 'prop' + }, + placeholder: 'This field has a placeholder' + } + ] +}; + +export const errors = null; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js index 641f724..22f7ce1 100644 --- a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js +++ b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js @@ -379,6 +379,16 @@ describe('validation', function() { testTemplate('called-element-missing-property'); }); + + + describe('placeholder', function() { + + testTemplate('placeholder'); + + testTemplate('placeholder-invalid-property'); + + testTemplate('placeholder-invalid-type'); + }); }); });