Skip to content

Commit

Permalink
Merge pull request #40 from molgenis/feat/missingValueQueries
Browse files Browse the repository at this point in the history
hasAny and anyHasAny missing value handling
  • Loading branch information
bartcharbon authored Jan 7, 2021
2 parents 0dca11e + 09d9c8e commit 4860995
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molgenis/vip-report-api",
"version": "0.5.0",
"version": "0.5.1",
"description": "Report API for Variant Call Format (VCF) Report Templates",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ function matchesIn(query: Query, resource: Resource): boolean {
function matchesAnyHasAny(query: Query, resource: Resource): boolean {
const value: any = select(query.selector, resource);

if (value === undefined) {
return false;
}

if (!Array.isArray(value)) {
throw new Error(`value '${value}' is of type '${typeof value}' instead of 'array'`);
}
Expand All @@ -405,6 +409,10 @@ function matchesAnyHasAny(query: Query, resource: Resource): boolean {
function matchesHasAny(query: Query, resource: Resource): boolean {
const value: any = select(query.selector, resource);

if (value === undefined) {
return false;
}

if (!Array.isArray(value)) {
throw new Error(`value '${value}' is of type '${typeof value}' instead of 'array'`);
}
Expand Down

0 comments on commit 4860995

Please sign in to comment.