Skip to content

Commit e768c63

Browse files
authored
docs: Add Python variant example of catching dataset validation errors (#1356)
Add Python variant example of catching dataset validation errors. Documents this change: apify/apify-client-python#314
2 parents a9ccbbb + c3c0cc0 commit e768c63

File tree

1 file changed

+16
-0
lines changed
  • sources/platform/actors/development/actor_definition/dataset_schema

1 file changed

+16
-0
lines changed

sources/platform/actors/development/actor_definition/dataset_schema/validation.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ description: Specify the dataset schema within the Actors so you can add monito
44
slug: /actors/development/actor-definition/dataset-schema/validation
55
---
66

7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
710
**Specify the dataset schema within the Actors so you can add monitoring and validation at the field level.**
811

912
---
@@ -105,6 +108,8 @@ The type of the AJV validation error object is [here](https://github.com/ajv-val
105108

106109
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:
107110

111+
<Tabs>
112+
<TabItem value="Javascript" label="Javascript" default>
108113
```javascript
109114
try {
110115
const response = await Actor.pushData(items);
@@ -115,6 +120,17 @@ try {
115120
});
116121
}
117122
```
123+
</TabItem>
124+
<TabItem value="Python" label="Python">
125+
```python
126+
try:
127+
await Actor.push_data(items)
128+
except ApifyApiError as error:
129+
if "invalidItems" in error.data:
130+
validation_errors = e.data["invalidItems"]
131+
```
132+
</TabItem>
133+
</Tabs>
118134
119135
## Examples of common types of validation
120136

0 commit comments

Comments
 (0)