Skip to content

Commit f8043f5

Browse files
committed
fix: use BIDS schema validator
This schema validator have format validation enabled which is needed to correctly validate a BIDS schema against the meta schema
1 parent e44ca11 commit f8043f5

File tree

1 file changed

+2
-3
lines changed
  • tools/schemacode/src/bidsschematools

1 file changed

+2
-3
lines changed

tools/schemacode/src/bidsschematools/schema.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from functools import cache, lru_cache
1010
from importlib.resources import files
1111

12-
from jsonschema import ValidationError, validate
12+
from jsonschema import ValidationError
1313
from jsonschema.protocols import Validator as JsonschemaValidator
1414

1515
from . import __bids_version__, __version__, utils
@@ -301,12 +301,11 @@ def filter_schema(schema, **kwargs):
301301

302302
def validate_schema(schema: Namespace):
303303
"""Validate a schema against the BIDS metaschema."""
304-
metaschema = json.loads(files("bidsschematools.data").joinpath("metaschema.json").read_text())
305304

306305
# validate is put in this try/except clause because the error is sometimes too long to
307306
# print in the terminal
308307
try:
309-
validate(instance=schema.to_dict(), schema=metaschema)
308+
get_schema_validator().validate(instance=schema.to_dict())
310309
except ValidationError as e:
311310
with tempfile.NamedTemporaryFile(
312311
prefix="schema_error_", suffix=".txt", delete=False, mode="w+"

0 commit comments

Comments
 (0)