ehn-dcc-development / eu-dcc-schema

Schema for the ehn DCC payload
Apache License 2.0
164 stars 59 forks source link

valueset validation #54

Closed rho-sk closed 3 years ago

rho-sk commented 3 years ago

What library do you use for valuesets validation. I am looking for python implementation if possible. Thnx.

miguelzapaton commented 3 years ago

That's an interesting point. In the following spec (in the chapter "Annex B JSON schema")...

https://ec.europa.eu/health/sites/health/files/ehealth/docs/digital-green-certificates_dt-specifications_en.pdf

... values are coded in JSON Schema notation (draft-07) which also would allow validating data with the same standard mechanism (Ajv).

Or did I miss anything and the "ValueSets" are a new feature of JSON Schema 2020_12 and can be also validated with Ajv?

Currently it seems that the samples in the test/invalid folder are only validated by structure, aren't they?

If this is the case, what's the reason and advantage that you work with the "ValueSet" notation instead of JSON Schema data validation right now?

Cheers!

Miguel

jschlyter commented 3 years ago

The value sets are not part of the JSON schema, they are indirect lookup tables used since JSON schemata cannot have external references to enum values.

We initially had the the values declared as enum, but choose this path as the list of allowed values are expected to change more frequently than the schema itself. Frequent schema changes was considered more difficult to work with for implementors.

miguelzapaton commented 3 years ago

I see your point about frequent schema changes.

Regarding external references please feel free to have a look at my proof of concept fork to see how enum validation can be done with $ref.:

https://github.com/miguelzapaton/ehn-dgc-schema

The use of "const" combined with "oneOf" is just an alternative JSON Schema syntax for enum.

As you can see, validation fails now, when there's no corresponding vaccine manufacturer entry in valueschemas/vaccine-mah-manf.json

This would allow specifying a standard mechanism to fully verify the DGC-JSON.

Miguel

gabywh commented 3 years ago

ValueSets:

please feel free to have a look at my proof of concept fork to see how enum validation can be done with $ref.:

feel free to issue a pull request from your fork to this repo and we can take a look

HTH, Gaby

gabywh commented 3 years ago

What library do you use for valuesets validation. I am looking for python implementation if possible. Thnx.

@rho-sk you could try e.g. this https://python-jsonschema.readthedocs.io/en/stable/validate/ However, do please be aware that "validate the JSON schema" is only one half of the story - you will almost certainly also need some business rules, see e.g. https://github.com/ehn-digital-green-development/ehn-dgc-schema/wiki/FAQ#what-do-the-typical-processing-stages-look-like-for

martin-lindstrom commented 3 years ago

For Java-users: The https://github.com/ehn-digital-green-development/dgc-java libraries now has support for value-set validation, both "static" where files hard-wired into the jar are used and "dynamic" where you use a reloadable value-set.

gabywh commented 3 years ago

@rho-sk I'll close if no further comments / questions from your side?

rho-sk commented 3 years ago

What library do you use for valuesets validation. I am looking for python implementation if possible. Thnx.

@rho-sk you could try e.g. this https://python-jsonschema.readthedocs.io/en/stable/validate/ However, do please be aware that "validate the JSON schema" is only one half of the story - you will almost certainly also need some business rules, see e.g. https://github.com/ehn-digital-green-development/ehn-dgc-schema/wiki/FAQ#what-do-the-typical-processing-stages-look-like-for

I already implemented schema and value validation in python for that, thx.

sanghvibk commented 3 years ago

I already implemented schema and value validation in python for that, thx.

I am also looking for Python library to perform Valueset validation. Would appreciate if I could get some pointers.

Thank you. Bhavin