Skip to content

Commit

Permalink
@W-14003910: readiness: warn on literal null filter value if operator…
Browse files Browse the repository at this point in the history
… is not Equals nor NotEquals (#162)

* show warning if using null values for unexpected filter operator

* add unit test

* fix for a regression

* remove not needed if check

* add expected valid null check
  • Loading branch information
selinaZhaoSF authored Sep 11, 2023
1 parent 883a7b7 commit adec218
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@
"description": "The value to compare against. This can use ${...} expressions."
}
},
"if": {
"properties": {
"operator": { "enum": ["LessThan", "LessThanEqual", "GreaterThan", "GreaterThanEqual", "In", "NotIn"] }
},
"required": ["operator"]
},
"then": {
"properties": {
"value": {
"type": ["string", "number", "boolean", "array"],
"description": "The value to compare against. This can use ${...} expressions."
}
}
},
"required": ["field", "operator", "value"],
"defaultSnippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ describe('readiness-schema.json finds errors in', () => {
'definition.datacloud.object'
);
});

it('invalid-values.json', async () => {
const errors = await validate('invalid-values.json');
errors.expectInvalidProps(
false,
'templateRequirements[0].type',
'definition.empty.type',
'definition.bad.type',
'definition.filterOp.filters[0].value',
'definition.filterOp.filters[1].value',
'definition.filterOp.filters[2].value',
'definition.filterOp.filters[3].value',
'definition.filterOp.filters[4].value',
'definition.filterOp.filters[5].value'
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"templateRequirements": [
{
"expression": "${true}",
"type": "error"
}
],
"definition": {
"empty": {
"type": ""
},
"bad": {
"type": "error"
},
"filterOp": {
"type": "SobjectRowCount",
"sobject": "foo",
"filters": [
{
"field": "field",
"operator": "GreaterThan",
"value": null
},
{
"field": "field",
"operator": "GreaterThanEqual",
"value": null
},
{
"field": "field",
"operator": "LessThan",
"value": null
},
{
"field": "field",
"operator": "LessThanEqual",
"value": null
},
{
"field": "field",
"operator": "NotIn",
"value": null
},
{
"field": "field",
"operator": "In",
"value": null
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"type": "SobjectRowCount",
"sobject": "Account",
"filters": null
},
"filterOp": {
"type": "SobjectRowCount",
"sobject": "foo",
"filters": [
{
"field": "field",
"operator": "Equal",
"value": null
}
]
}
}
}

0 comments on commit adec218

Please sign in to comment.