Skip to content

Commit

Permalink
feat: Enable schema validator for any derivative datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Sep 15, 2023
1 parent 2251066 commit 4770ae7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/openneuro-app/src/scripts/uploader/upload-issues.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,27 @@ class UploadValidator extends React.Component {
if (this.props.schemaValidator) {
schemaValidate(this.props.files, options).then(this.done)
} else {
validate(this.props.files, options).then(this.done)
// Test for dataset_description.json and use the schemaValidator for DatasetType == 'derivative'
// Fall back if anything fails
const dsDescription = Array.from(this.props.files).find(
f => f.name === 'dataset_description.json',
)
if (dsDescription) {
dsDescription.text().then(dsDescriptionData => {
try {
const descriptionFields = JSON.parse(dsDescriptionData)
if (descriptionFields.DatasetType === 'derivative') {
schemaValidate(this.props.files, options).then(this.done)
} else {
validate(this.props.files, options).then(this.done)
}
} catch (err) {
validate(this.props.files, options).then(this.done)
}
})
} else {
validate(this.props.files, options).then(this.done)
}
}
}

Expand Down

0 comments on commit 4770ae7

Please sign in to comment.