Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Python variant example of catching dataset validation errors #1356

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading