iiif-prezi / iiif-prezi3

IIIF Presentation API 3 Python Library
https://iiif-prezi.github.io/iiif-prezi3/
Apache License 2.0
27 stars 14 forks source link

Extra validators for Canvas/HWD properties #144

Open digitaldogsbody opened 1 year ago

digitaldogsbody commented 1 year ago

The specification as written says

A Canvas MUST have a rectangular aspect ratio (described with the height and width properties) and/or a duration to provide an extent in time.

Although the JSON Schema validates this (https://github.com/IIIF/presentation-validator/blob/main/schema/iiif_3_0.json#L635-L643) with anyOf hwd and making h&w dependent on each other - this validation does not come through when the Pydantic model is generated by datamodel-code-generator and all three fields end up being wrapped in Optional.

We could build a custom validator for this (https://docs.pydantic.dev/usage/validators/) and add it to the class with the new skeleton modification script

glenrobson commented 1 year ago

Discussed this on the call 13th Jan we think this would be useful and could be injected with the skeleton agenda.