From 070a31dcc8d9a811873953e11a74feb1dd65b619 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 25 Oct 2024 13:45:20 -0400 Subject: [PATCH 1/2] fix(cli): Allow blacklisting any modality from schema.rules.modalities --- bids-validator/src/setup/options.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bids-validator/src/setup/options.ts b/bids-validator/src/setup/options.ts index 34fb03944..76aa10f1d 100644 --- a/bids-validator/src/setup/options.ts +++ b/bids-validator/src/setup/options.ts @@ -3,6 +3,7 @@ import type { LevelName } from '@std/log' import { Command, EnumType } from '@cliffy/command' import { getVersion } from '../version.ts' import type { Issue, Severity } from '../types/issues.ts' +import { schema } from '@bids/schema' /** * BIDS Validator config file object definition @@ -31,7 +32,7 @@ export type ValidatorOptions = { } const modalityType = new EnumType( - ['MRI', 'PET', 'MEG', 'EEG', 'iEEG', 'Microscopy', 'NIRS', 'MRS'], + Object.keys(schema.rules.modalities) ) /** Extendable Cliffy Command with built in BIDS validator options */ From 525163be02c3d75da0e50369f2a230020cd15d5a Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 25 Oct 2024 13:59:50 -0400 Subject: [PATCH 2/2] Log a warning if an unknown modality is blacklisted --- bids-validator/src/validators/bids.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bids-validator/src/validators/bids.ts b/bids-validator/src/validators/bids.ts index 4f5b8cc20..c51b94855 100644 --- a/bids-validator/src/validators/bids.ts +++ b/bids-validator/src/validators/bids.ts @@ -18,6 +18,7 @@ import { type BIDSContext, BIDSContextDataset } from '../schema/context.ts' import type { parseOptions } from '../setup/options.ts' import { hedValidate } from './hed.ts' import { citationValidate } from './citation.ts' +import { logger } from '../utils/logger.ts' /** * Ordering of checks to apply @@ -121,8 +122,12 @@ export async function validate( // Map blacklisted datatypes back to the modality that generated them for (const modality of options.blacklistModalities) { const datatypes = modalitiesRule[modality.toLowerCase()]?.datatypes as string[] - for (const datatype of datatypes) { - blacklistedDatatypes.set(datatype, modality) + if (datatypes) { + for (const datatype of datatypes) { + blacklistedDatatypes.set(datatype, modality) + } + } else { + logger.warn(`Attempted to blacklist unknown modality: ${modality}`) } } }