Skip to content

Commit

Permalink
#1314: ensure selected subtypes actually exist
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 13, 2024
1 parent 466a38d commit 7fb672b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ class Asset extends MetadataType {
*/
static async retrieve(retrieveDir, _, subTypeArr, key) {
const items = [];
if (subTypeArr) {
// check if elements in subTypeArr exist in this.definition.subTypes
const invalidSubTypes = subTypeArr.filter(
(subType) => !this.definition.subTypes.includes(subType)
);
if (invalidSubTypes.length) {
throw new Error(`Invalid subType(s) found: ${invalidSubTypes.join(', ')}`);
}
}
subTypeArr ||= this._getSubTypes();
if (retrieveDir) {
await File.initPrettier();
Expand Down

0 comments on commit 7fb672b

Please sign in to comment.