Skip to content

Commit

Permalink
Throw errors for missing parameters. Do not default match-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Nov 16, 2021
1 parent f0ed4e9 commit b7a6080
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/AbstractReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ class AbstractReader {
});
}

filter({resourceTagCollection, filters, any = true}) {
filter({resourceTagCollection, matchMode, filters}) {
const ReaderFilter = require("./ReaderFilter");
return new ReaderFilter({
reader: this,
resourceTagCollection,
filters,
any
matchMode,
filters
});
}

Expand Down
17 changes: 15 additions & 2 deletions lib/ReaderFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@ class ReaderFilter extends AbstractReader {
* @param {module:@ui5/fs.ResourceTagCollection} parameters.resourceTagCollection
* Resource tag collection to apply filters onto
* @param {object[]} parameters.filters Filters
* @param {string} [parameters.matchMode="any"] Whether to match any, all or none
* @param {string} parameters.matchMode Whether to match "any", "all" or "none"
*/
constructor({reader, resourceTagCollection, filters, matchMode = "any"}) {
constructor({reader, resourceTagCollection, filters, matchMode}) {
super();
if (!reader) {
throw new Error(`Missing parameter "reader"`);
}
if (!resourceTagCollection) {
throw new Error(`Missing parameter "resourceTagCollection"`);
}
if (!filters || !filters.length) {
throw new Error(`Missing parameter "filters"`);
}
if (!matchMode) {
throw new Error(`Missing parameter "matchMode"`);
}
this._reader = reader;
this._resourceTagCollection = resourceTagCollection;
this._filters = filters;

this._matchMode = matchMode;
}

Expand Down

0 comments on commit b7a6080

Please sign in to comment.