Skip to content

Commit

Permalink
feat(condition): add isActive condition
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Nov 22, 2023
1 parent 88f93d4 commit 2ab4d91
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
"required": [
"oneOf"
]
},
{
"properties": {
"isActive": {
"type": "boolean",
"description": "For `true`, activates the property when given property is active"
}
},
"required": [
"isActive"
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down Expand Up @@ -100,6 +109,15 @@ export const errors = [
params: { type: [ 'string', 'number' ] },
message: 'should be string,number'
},
{
dataPath: '/properties/2/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/2/condition',
Expand Down
12 changes: 12 additions & 0 deletions packages/element-templates-json-schema/test/fixtures/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ export const template = {
'type': 'property',
'name': 'input4'
}
},
{
'label': 'isActive',
'type': 'String',
'condition': {
property: 'myId',
isActive: true
},
'binding': {
'type': 'property',
'name': 'input4'
}
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ export const errors = [
},
'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required'
},
{
'dataPath': '/properties/2/condition',
'keyword': 'required',
'message': "should have required property 'isActive'",
'params': {
'missingProperty': 'isActive'
},
'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
'dataPath': '/properties/2/condition',
'keyword': 'oneOf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ export const errors = [
params: { missingProperty: 'oneOf' },
message: "should have required property 'oneOf'"
},
{
dataPath: '/properties/1/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/1/condition',
Expand Down Expand Up @@ -100,6 +109,15 @@ export const errors = [
params: { type: [ 'string', 'number' ] },
message: 'should be string,number'
},
{
dataPath: '/properties/2/condition',
keyword: 'required',
message: "should have required property 'isActive'",
params: {
missingProperty: 'isActive'
},
schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required'
},
{
keyword: 'oneOf',
dataPath: '/properties/2/condition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ export const template = {
'type': 'property',
'name': 'input4'
}
},
{
'label': 'isActive',
'type': 'String',
'condition': {
property: 'myId',
isActive: true
},
'binding': {
'type': 'property',
'name': 'input4'
}
}
]
};
Expand Down

0 comments on commit 2ab4d91

Please sign in to comment.