usnistgov / E3

API that provides standards based economic calculations.
Other
6 stars 3 forks source link

Feature: Accumulate errors up to limit, BCN and Analysis Serializer #29

Closed tashakim closed 3 years ago

tashakim commented 3 years ago

Description

This PR adds a way to accumulate all validation errors in BcnSerializer and AnalysisSerializer before throwing NUM_ERRORS_LIMIT number of Exceptions after validation. Note: NUM_ERRORS_LIMIT is the maximum number of errors that are displayed to the user when an error occurs, and can be changed from /e3_django/API/variables.

For example, NUM_ERRORS_LIMIT=5 will display up to 5 errors that occurred while creating the object, to the user.

Motivation and Context

Prior to this change, both BcnSerializer and AnalysisSerializer threw a ValidationError upon discovering a single error. This was inconvenient especially when user was providing a large number of inputs, because the user had to go back and fix one error, send a request, fix the next error, send another request, and so on, to fix all the issues in calculation (if more than one error occurred).

Closes #12

tashakim commented 3 years ago

Once PR #31 is accepted, this PR must be updated accordingly before merge (or vice versa).