Skip to content

Commit

Permalink
docs: Add Python variant example of catching dataset validation errors (
Browse files Browse the repository at this point in the history
#1356)

Add Python variant example of catching dataset validation errors.

Documents this change:
apify/apify-client-python#314
  • Loading branch information
Pijukatel authored Dec 16, 2024
2 parents a9ccbbb + c3c0cc0 commit e768c63
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.**

---
Expand Down Expand Up @@ -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:

<Tabs>
<TabItem value="Javascript" label="Javascript" default>
```javascript
try {
const response = await Actor.pushData(items);
Expand All @@ -115,6 +120,17 @@ try {
});
}
```
</TabItem>
<TabItem value="Python" label="Python">
```python
try:
await Actor.push_data(items)
except ApifyApiError as error:
if "invalidItems" in error.data:
validation_errors = e.data["invalidItems"]
```
</TabItem>
</Tabs>
## Examples of common types of validation
Expand Down

0 comments on commit e768c63

Please sign in to comment.