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.
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.