Skip to content

Commit

Permalink
Enrichi l'objet erreur retour
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Feb 10, 2025
1 parent aac7a7a commit 4b4d446
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/views/purchaseimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def post(self, request):

# Step 2: Schema validation (Validata)
report = validate_file_against_schema(self.file, self.schema_url)
print(report["tasks"][0]["errors"])
self.errors = process_errors(report)
if len(self.errors):
self._log_error("Echec lors de la validation du fichier (schema achats.json - Validata)")
Expand Down
10 changes: 7 additions & 3 deletions common/api/validata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ def process_errors(report):
for error in report["tasks"][0]["errors"]:
errors.append(
{
"row": error["rowNumber"],
"status": 400,
"column": error["fieldName"],
# cells, description, fieldNumber, name, note, rowNumber, tags, type
"row": error["rowPosition"],
"column": error["fieldPosition"],
"field": error["fieldName"],
"cell": error["cell"],
"title": error["title"],
"message": error["message"],
"code": error["code"],
"status": 400,
}
)
return errors

0 comments on commit 4b4d446

Please sign in to comment.