From c3c0cc0f4310021b37f04a0d80f00174d7df2c9b Mon Sep 17 00:00:00 2001 From: Josef Prochazka Date: Fri, 13 Dec 2024 15:30:44 +0100 Subject: [PATCH] Add Python variant example of catching dataset validation errors. --- .../dataset_schema/validation.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sources/platform/actors/development/actor_definition/dataset_schema/validation.md b/sources/platform/actors/development/actor_definition/dataset_schema/validation.md index 882b614e95..e96c9def67 100644 --- a/sources/platform/actors/development/actor_definition/dataset_schema/validation.md +++ b/sources/platform/actors/development/actor_definition/dataset_schema/validation.md @@ -4,6 +4,9 @@ description: Specify the dataset schema within the Actors so you can add monito slug: /actors/development/actor-definition/dataset-schema/validation --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + **Specify the dataset schema within the Actors so you can add monitoring and validation at the field level.** --- @@ -105,6 +108,8 @@ The type of the AJV validation error object is [here](https://github.com/ajv-val If you use the Apify JS client or Apify SDK and call `pushData` function you can access the validation errors in a `try catch` block like this: + + ```javascript try { const response = await Actor.pushData(items); @@ -115,6 +120,17 @@ try { }); } ``` + + +```python +try: + await Actor.push_data(items) +except ApifyApiError as error: + if "invalidItems" in error.data: + validation_errors = e.data["invalidItems"] +``` + + ## Examples of common types of validation