Skip to content

Commit

Permalink
chore: improve feel prop validation
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm authored and merge-me[bot] committed Mar 14, 2022
1 parent ac43f50 commit a950c47
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "List of properties of the element template.",
"allOf": [
{ "$ref": "examples.json#/properties" }
],
],
"items": {
"type": "object",
"default": {},
Expand All @@ -25,31 +25,6 @@
],
"errorMessage": "must provide choices=[] with \"Dropdown\" type"
}
},
{
"if": {
"not": {
"properties": {
"type": {
"enum": [
"String",
"Text"
]
}
},
"required": [
"type"
]
}
},
"then": {
"not": {
"required": [
"feel"
]
},
"errorMessage": "feel is only valid for \"String\" and \"Text\" type"
}
}
],
"properties": {
Expand Down Expand Up @@ -159,18 +134,6 @@
}
}
},
"feel": {
"$id": "#/properties/property/feel",
"type": "string",
"default": null,
"title": "property feel",
"description": "Indicates whether the property can be a feel expression",
"enum": [
null,
"optional",
"required"
]
},
"group": {
"$id": "#/properties/property/group",
"type": "string",
Expand Down
37 changes: 0 additions & 37 deletions packages/element-templates-json-schema/resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,6 @@
],
"errorMessage": "must provide choices=[] with \"Dropdown\" type"
}
},
{
"if": {
"not": {
"properties": {
"type": {
"enum": [
"String",
"Text"
]
}
},
"required": [
"type"
]
}
},
"then": {
"not": {
"required": [
"feel"
]
},
"errorMessage": "feel is only valid for \"String\" and \"Text\" type"
}
}
],
"properties": {
Expand Down Expand Up @@ -185,18 +160,6 @@
}
}
},
"feel": {
"$id": "#/properties/property/feel",
"type": "string",
"default": null,
"title": "property feel",
"description": "Indicates whether the property can be a feel expression",
"enum": [
null,
"optional",
"required"
]
},
"group": {
"$id": "#/properties/property/group",
"type": "string",
Expand Down
76 changes: 39 additions & 37 deletions packages/zeebe-element-templates-json-schema/resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,6 @@
],
"errorMessage": "must provide choices=[] with \"Dropdown\" type"
}
},
{
"if": {
"not": {
"properties": {
"type": {
"enum": [
"String",
"Text"
]
}
},
"required": [
"type"
]
}
},
"then": {
"not": {
"required": [
"feel"
]
},
"errorMessage": "feel is only valid for \"String\" and \"Text\" type"
}
}
],
"properties": {
Expand Down Expand Up @@ -185,18 +160,6 @@
}
}
},
"feel": {
"$id": "#/properties/property/feel",
"type": "string",
"default": null,
"title": "property feel",
"description": "Indicates whether the property can be a feel expression",
"enum": [
null,
"optional",
"required"
]
},
"group": {
"$id": "#/properties/property/group",
"type": "string",
Expand Down Expand Up @@ -347,6 +310,34 @@
}
}
}
},
{
"if": {
"properties": {
"feel": {
"not": {
"const": null
}
}
},
"required": [
"feel"
]
},
"then": {
"properties": {
"type": {
"enum": [
"String",
"Text"
],
"errorMessage": "feel is only supported for \"String\" and \"Text\" type"
}
},
"required": [
"type"
]
}
}
],
"properties": {
Expand Down Expand Up @@ -474,6 +465,17 @@
"$id": "#/optional",
"type": "boolean",
"description": "Indicates whether a property is optional. Optional bindings do not persist empty values in the underlying BPMN 2.0 XML."
},
"feel": {
"$id": "#/properties/property/feel",
"type": "string",
"default": null,
"description": "Indicates whether the property can be a feel expression",
"enum": [
null,
"optional",
"required"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@
}
}
}
},
{
"if": {
"properties": {
"feel": {
"not": {
"const": null
}
}
},
"required": [
"feel"
]
},
"then": {
"properties": {
"type": {
"enum": [
"String",
"Text"
],
"errorMessage": "feel is only supported for \"String\" and \"Text\" type"
}
},
"required": [
"type"
]
}
}
],
"properties": {
Expand Down Expand Up @@ -247,6 +275,17 @@
"$id": "#/optional",
"type": "boolean",
"description": "Indicates whether a property is optional. Optional bindings do not persist empty values in the underlying BPMN 2.0 XML."
},
"feel": {
"$id": "#/properties/property/feel",
"type": "string",
"default": null,
"description": "Indicates whether the property can be a feel expression",
"enum": [
null,
"optional",
"required"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,52 @@ export const template = {
export const errors = [
{
keyword: 'errorMessage',
dataPath: '/properties/0',
schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/then/errorMessage',
dataPath: '/properties/0/type',
schemaPath: '#/definitions/properties/allOf/1/items/allOf/4/then/properties/type/errorMessage',
params: {
errors: [
{
dataPath: '/properties/0',
emUsed: true,
keyword: 'not',
message: 'should NOT be valid',
params: {},
schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/then/not'
keyword: 'enum',
dataPath: '/properties/0/type',
schemaPath: '#/definitions/properties/allOf/1/items/allOf/4/then/properties/type/enum',
params: {
allowedValues: [
'String',
'Text'
]
},
message: 'should be equal to one of the allowed values',
emUsed: true
}
]
},
message: 'feel is only valid for "String" and "Text" type'
message: 'feel is only supported for "String" and "Text" type'
},
{
keyword: 'if',
dataPath: '/properties/0',
schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/if',
params: { failingKeyword: 'then' },
schemaPath: '#/definitions/properties/allOf/1/items/allOf/4/if',
params: {
failingKeyword: 'then'
},
message: 'should match "then" schema'
},
{
keyword: 'type',
dataPath: '',
schemaPath: '#/oneOf/1/type',
params: { type: 'array' },
params: {
type: 'array'
},
message: 'should be array'
},
{
keyword: 'oneOf',
dataPath: '',
schemaPath: '#/oneOf',
params: { passingSchemas: null },
params: {
passingSchemas: null
},
message: 'should match exactly one schema in oneOf'
}
];

0 comments on commit a950c47

Please sign in to comment.