veres-one / veres-one-validator

A ledger validator that accepts either signatures or proof of work
Other
3 stars 0 forks source link

Audit the validation schemas #11

Open mattcollier opened 5 years ago

mattcollier commented 5 years ago

Reminder to reevaluate the validation schemas after all the signature and PoW algorithms are finalized.

mattcollier commented 4 years ago

This is still outstanding. There are numerous TODOs and FIXMEs in the schema document as well as some very lax placeholder validation that needs to be tightened up.

https://github.com/veres-one/veres-one-validator/tree/master/schemas

mattcollier commented 4 years ago

We are using ajv@6 which support JSON schema draft 7 which includes conditionals:

https://json-schema.org/understanding-json-schema/reference/conditionals.html

It appears that in combination with allOf as shown in the example on this page, we can see great benefit by doing conditionals based on the JSONLD type of documents.

We are likely to see a performance benefit vs our current usage of anyOf for validating multiple document types and I expect that the resulting validation errors will be much more concise and to the point instead of telling us why a document failed against each and every one of the schemas in the anyOf array.

I note also that there may be opportunities to use the const keyword in place of enum with a single value: https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values