Skip to content

Commit d2c9fbb

Browse files
authored
Merge pull request #2176 from effigies/fix/blacklist-inputs
fix(cli): Allow blacklisting any modality from schema.rules.modalities
2 parents f40d4de + 525163b commit d2c9fbb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

bids-validator/src/setup/options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { LevelName } from '@std/log'
33
import { Command, EnumType } from '@cliffy/command'
44
import { getVersion } from '../version.ts'
55
import type { Issue, Severity } from '../types/issues.ts'
6+
import { schema } from '@bids/schema'
67

78
/**
89
* BIDS Validator config file object definition
@@ -31,7 +32,7 @@ export type ValidatorOptions = {
3132
}
3233

3334
const modalityType = new EnumType<string>(
34-
['MRI', 'PET', 'MEG', 'EEG', 'iEEG', 'Microscopy', 'NIRS', 'MRS'],
35+
Object.keys(schema.rules.modalities)
3536
)
3637

3738
/** Extendable Cliffy Command with built in BIDS validator options */

bids-validator/src/validators/bids.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { type BIDSContext, BIDSContextDataset } from '../schema/context.ts'
1818
import type { parseOptions } from '../setup/options.ts'
1919
import { hedValidate } from './hed.ts'
2020
import { citationValidate } from './citation.ts'
21+
import { logger } from '../utils/logger.ts'
2122

2223
/**
2324
* Ordering of checks to apply
@@ -121,8 +122,12 @@ export async function validate(
121122
// Map blacklisted datatypes back to the modality that generated them
122123
for (const modality of options.blacklistModalities) {
123124
const datatypes = modalitiesRule[modality.toLowerCase()]?.datatypes as string[]
124-
for (const datatype of datatypes) {
125-
blacklistedDatatypes.set(datatype, modality)
125+
if (datatypes) {
126+
for (const datatype of datatypes) {
127+
blacklistedDatatypes.set(datatype, modality)
128+
}
129+
} else {
130+
logger.warn(`Attempted to blacklist unknown modality: ${modality}`)
126131
}
127132
}
128133
}

0 commit comments

Comments
 (0)