Skip to content

Commit

Permalink
Merge pull request #229 from VisLab/update-tokenizer
Browse files Browse the repository at this point in the history
Completed implementation of HED validator
  • Loading branch information
VisLab authored Dec 23, 2024
2 parents 3ef09a9 + 662e772 commit afe0e3e
Show file tree
Hide file tree
Showing 74 changed files with 6,480 additions and 15,096 deletions.
2 changes: 1 addition & 1 deletion bids/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import castArray from 'lodash/castArray'
import semver from 'semver'

import { buildSchemas } from '../schema/init'
import { generateIssue, IssueError } from '../common/issues/issues'
import { IssueError } from '../common/issues/issues'
import { SchemaSpec, SchemasSpec } from '../schema/specs'

const alphabeticRegExp = new RegExp('^[a-zA-Z]+$')
Expand Down
21 changes: 17 additions & 4 deletions bids/types/basic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BidsHedIssue } from './issues'
import { generateIssue } from '../../common/issues/issues'

/**
* A BIDS file.
Expand Down Expand Up @@ -36,15 +37,27 @@ export class BidsFile {
return false
}

validate(hedSchemas) {
/**
* Validate this validator's tsv file
*
* @param {Schemas} schemas
* @returns {BidsIssue[]} Any issues found during validation of this TSV file.
*/
validate(schemas) {
if (!this.hasHedData()) {
return []
} else if (hedSchemas === null) {
return null
}
if (!schemas) {
BidsHedIssue.fromHedIssue(
generateIssue('genericError', {
message: 'BIDS file HED validation requires a HED schema, but the schema received was null.',
}),
{ path: this.file.file, relativePath: this.file.file },
)
}

try {
const validator = new this.validatorClass(this, hedSchemas)
const validator = new this.validatorClass(this, schemas)
return validator.validate()
} catch (internalError) {
return BidsHedIssue.fromHedIssues(internalError, this.file)
Expand Down
4 changes: 1 addition & 3 deletions bids/types/dataset.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { fallbackDatasetDescription } from './json'

export class BidsDataset {
/**
* The dataset's event file data.
Expand All @@ -22,7 +20,7 @@ export class BidsDataset {
*/
datasetRootDirectory

constructor(eventData, sidecarData, datasetDescription = fallbackDatasetDescription, datasetRootDirectory = null) {
constructor(eventData, sidecarData, datasetDescription, datasetRootDirectory = null) {
this.eventData = eventData
this.sidecarData = sidecarData
this.datasetDescription = datasetDescription
Expand Down
2 changes: 1 addition & 1 deletion bids/types/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BidsIssue {
* Determine if any of the passed issues are errors.
*
* @param {BidsIssue[]} issues A list of issues.
* @return {boolean} Whether any of the passed issues are errors (rather than warnings).
* @returns {boolean} Whether any of the passed issues are errors (rather than warnings).
*/
static anyAreErrors(issues) {
return issues.some((issue) => issue.isError())
Expand Down
Loading

0 comments on commit afe0e3e

Please sign in to comment.