Skip to content

Commit f4d7c40

Browse files
authored
Merge pull request #1009 from bids-standard/1008_add_datasettype_to_dsdesc
add DataType to dataset_description.json schema
2 parents f4677cd + 1d6f9c9 commit f4d7c40

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

bids-validator/tests/json.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,46 @@ describe('JSON', function() {
306306
assert(issues.length === 1 && issues[0].code == 55)
307307
})
308308
})
309+
310+
var dataset_description_file = {
311+
name: 'dataset_description.json',
312+
relativePath: '/dataset_description.json',
313+
}
314+
315+
it('dataset_description.json should validate with enum of DatasetType', function() {
316+
var jsonObj = {
317+
Name: 'Example Name',
318+
BIDSVersion: '1.4.0',
319+
Authors: ['example author'],
320+
DatasetType: 'raw',
321+
}
322+
jsonDict[dataset_description_file.relativePath] = jsonObj
323+
validate.JSON(dataset_description_file, jsonDict, function(issues) {
324+
assert(issues.length === 0)
325+
})
326+
})
327+
328+
it('dataset_description.json should NOT validate with wrong enum of DatasetType', function() {
329+
var jsonObj = {
330+
Name: 'Example Name',
331+
BIDSVersion: '1.4.0',
332+
Authors: ['example author'],
333+
DatasetType: 'badenum',
334+
}
335+
jsonDict[dataset_description_file.relativePath] = jsonObj
336+
validate.JSON(dataset_description_file, jsonDict, function(issues) {
337+
assert(issues.length === 1 && issues[0].code == 55)
338+
})
339+
})
340+
341+
it('dataset_description.json should validate with only required fields, no recommended', function() {
342+
var jsonObj = {
343+
Name: 'Example Name',
344+
BIDSVersion: '1.4.0',
345+
}
346+
jsonDict[dataset_description_file.relativePath] = jsonObj
347+
validate.JSON(dataset_description_file, jsonDict, function(issues) {
348+
assert(issues.length === 0)
349+
})
350+
})
309351
})

bids-validator/validators/json/schemas/dataset_description.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"DatasetDOI": {
4545
"type": "string"
4646
},
47+
"DatasetType": {
48+
"type": "string",
49+
"enum": ["raw", "derivative"]
50+
},
4751
"Genetics": {
4852
"type": "object",
4953
"properties": {

0 commit comments

Comments
 (0)