YangCatalog / backend

YANG Catalog's REST API and internal module processing pipeline
https://yangcatalog.org
Apache License 2.0
2 stars 11 forks source link

Factor out and generalize logic for checking validity of JSON data #760

Closed richardzilincikPantheon closed 1 year ago

richardzilincikPantheon commented 1 year ago

Each view function that expects a request with a JSON body currently attempts to do validation and error handling on it's own. This means each function's error handling must be tested separately, and error messages do not have a unified format.

A better approach would be to factor out the validation logic. Each view function could specify the expected JSON shape declaratively and pass the description along with the data to a separate validation function.