psych-ds / psychds-validator

Validator tools for the psych-DS specification
1 stars 1 forks source link

Updates relating to JSON-LD and Schema.org validation [closes #26 and #7] #29

Closed bleonar5 closed 8 months ago

bleonar5 commented 9 months ago

Pull request to close issues #7 and #26

Adds support for JSON-LD validation by using the jsonld npm library to expand metadata objects and propagate context to all properties/types within. Pipes JSON-LD syntax errors into validator issue output using the expand function. Expand function also allows us to handle the usage of various valid JSON-LD formats, such as compacted (which our canonical examples use) and already-expanded. In addition, JSON-LD expansion handles the fact that bare strings, unitary arrays of strings, and untyped objects with string @values are all legal JSON-LD values because the expanded form uses the latter untyped @value format.

JSON-LD Grammar resource JSON-LD Playground for ground truth testing

After testing and concluding that a JSON-Schema or SHACL-based approach was not feasible, I decided on a manual implementation of schema.org type checking, validating all root and sub-objects within the metadata for type and property restrictions according to the schema.org ontology. Recursive algorithms were implemented to handle hierarchical inheritance of type slots and object slots. A variety of new issue types were introduced, mostly warnings rather than errors, and future work may entail moving them more directly into the psych-DS schema model itself.

Schema.org web validator for ground truth Schema.org style conventions Schema.org ontology - web version Schema.org ontology - linkml version

Miscellaneous fixes and updates included the addition of standard JSON syntax validation and issue reporting, as well as fixes for certain problematic race conditions caused by asynchronous "allSettled" wrappers that inherited from BIDS but didn't fully understand.

@okaycj It was hard not to be obscure on the PR description without going into unnecessary detail and potentially wasting everyone's time. I've attempted to annotate my new contributions to the codebase thoroughly with inline comments. Please reach out for a video call if you want to do a fly-by overview, get into the weeds, or work through anything in particular. Thanks for taking a look.

bleonar5 commented 8 months ago

This is looking pretty good.

Is there a way to submit smaller PRs? The number of changes here is a touch unwieldy.

Yes, absolutely. In general, I will aim for smaller PRs moving forward.