This should be done both:
- when a real dataset is created
- during some unit tests
The recently released schema-based BIDS validator (including a python version) is here: https://bids-website.readthedocs.io/en/latest/blog/2024/11/13/bids-validator-2.html