# CSV & JSON Data Contract Validator (`honest_chainsaw/my-actor-3`) Actor

Validate CSV or JSON data against a data contract before import. Get a row-level report of type, format and rule errors.

- **URL**: https://apify.com/honest_chainsaw/my-actor-3.md
- **Developed by:** [EsusVogi](https://apify.com/honest_chainsaw) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 analysis-completeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CSV & JSON Data Contract Validator

Validate CSV or JSON data against a data contract before you import it. The Actor returns a structured, row-level report. It does not fetch URLs, does not change your data and does not import anything into another system.

### What it checks

- **Columns and fields:** required fields, allowed extra columns (off by default), duplicate column names.
- **Types:** string, identifier (keeps leading zeros), integer, decimal (`.` or `,` separator), ISO date, boolean, enumerated values.
- **Rules:** bounds (`min`, `max`), regular-expression patterns, maximum length, unique keys, duplicate rows, a field required when another field has a given value (`required_if`), and one date that must come before another (`date_order`).
- **Input formats:** CSV text, or a JSON array of objects (also accepts `{"rows": [...]}`).

### Limits

- 1,000,000 UTF-8 bytes of content
- 10,000 data rows
- 100 columns
- 4,096 characters per CSV cell
- At most 1,000 detailed findings are kept; additional findings are counted.

### Input

| Field | Type | Description |
|---|---|---|
| `contract` | object | The data contract: `format` (`csv` or `json`), `delimiter` (CSV), `columns`, optional rules. |
| `content` | string | The CSV or JSON text to validate. |
| `includeValues` | boolean | Default `false`. When `true`, the report shows cell values and column names. |

Example input (fictional data):

```json
{
  "contract": {
    "format": "csv",
    "delimiter": ",",
    "columns": [
      {"name": "sku", "type": "identifier", "required": true, "unique": true},
      {"name": "quantite", "type": "integer", "required": true, "min": 0}
    ]
  },
  "content": "sku,quantite\nDEMO-001,3\nDEMO-002,0\n",
  "includeValues": false
}
```

### Output

The report contains:

- `status`: `valid`, `valid_with_warnings`, `invalid` (completed with data errors), or `rejected` (file or contract could not be analysed reliably).
- `summary`: bytes, rows read, rows valid and invalid, errors, warnings, duplicate keys and duplicate rows.
- `findings`: row and line numbers, finding codes, severity. Values are hidden unless `includeValues` is `true`.

Example output for the input above (fictional data):

```json
{
  "validator": {"name": "csv-json-validator", "version": "0.3.0"},
  "contract_version": null,
  "status": "valid",
  "format": "csv",
  "summary": {
    "bytes": 35,
    "rows_read": 2,
    "rows_invalid": 0,
    "rows_valid": 2,
    "errors": 0,
    "warnings": 0,
    "duplicate_keys": 0,
    "duplicate_rows": 0
  },
  "findings": [],
  "findings_suppressed": 0,
  "findings_truncated": false
}
```

A complete report with a `billing` field is published to the run's `OUTPUT` record only when the charge is accepted (see Pricing). The dataset item contains the same report without the `billing` field.

### Pricing

- One billable event, `analysis-completed`, at **US$0.02 per completed analysis**.
- Billed only when at least one data row was analysed and the status is `valid`, `valid_with_warnings` or `invalid`. Data-rule violations can be `invalid` and billable.
- **Not billed:** a `rejected` file (for example a missing required column, a disallowed extra column, a field count that differs on any row, unreadable syntax), an empty file (a CSV header alone or `[]`), invalid input or contract, and technical errors.
- Billing is per analysis, not per row. A new run is a new analysis.
- If the run has no spending limit, or a limit below US$0.02, the run fails with a minimal message and no report.
- If the charge is refused or its outcome is unclear, the run fails with a minimal message and no report. The Actor does not retry the charge automatically.
- No platform start charge or dataset-item charge is applied, and platform usage is not passed on to users.

### Status

- `valid`: no data errors.
- `valid_with_warnings`: analysed, with warnings.
- `invalid`: analysed, with data errors.
- `rejected`: the file or contract could not be analysed reliably. Not billed.
- `failed`: the input was invalid, or a technical error, a missing or insufficient spending limit, or a charge refusal prevented a report. Not billed. No report is delivered.

### Privacy and data handling

- `includeValues: false` hides cell values, column names and unknown identifiers in the report. Finding codes and row numbers remain visible.
- **This is not anonymisation.** The `content` and `contract` you submit remain in the run's `INPUT` record on Apify. Reports remain in the run's storages under Apify's access and retention settings. This Actor does not promise automatic deletion.
- Do not submit personal or confidential data unless you have the right to process it and you have reviewed the platform's storage settings.
- Set `includeValues: true` only when you need detailed values in the report, and only if you are authorised to process them.
- The Actor runs with **limited permissions**: it uses only its own run storages, its request queue and the charge for the current run.

### Issues and support

Use the Actor's **Issues** tab on Apify Store. Do not include secrets or personal information in public reports.

# Actor input Schema

## `contract` (type: `object`):

JSON contract: csv or json format, columns (name, type, required, unique, bounds, pattern, values), optional cross-field rules.

## `content` (type: `string`):

Paste CSV or JSON text. Maximum 1,000,000 UTF-8 bytes. Avoid sensitive data unless you are authorized to process it on Apify.

## `includeValues` (type: `boolean`):

Off by default: values, findings.column and unknown identifiers are hidden in the report; findings.message is generic and contract_version is null. Finding codes and row numbers remain visible. Original content and contract remain in the Apify run INPUT storage. This setting does not anonymize that storage. Enable only when detailed output is needed and authorized.

## Actor input object example

```json
{
  "contract": {
    "format": "csv",
    "delimiter": ",",
    "columns": [
      {
        "name": "sku",
        "type": "identifier",
        "required": true,
        "unique": true
      },
      {
        "name": "quantite",
        "type": "integer",
        "required": true,
        "min": 0
      }
    ]
  },
  "content": "sku,quantite\nDEMO-001,3\nDEMO-002,0\n",
  "includeValues": false
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `items` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "contract": {
        "format": "csv",
        "delimiter": ",",
        "columns": [
            {
                "name": "sku",
                "type": "identifier",
                "required": true,
                "unique": true
            },
            {
                "name": "quantite",
                "type": "integer",
                "required": true,
                "min": 0
            }
        ]
    },
    "content": `sku,quantite
DEMO-001,3
DEMO-002,0`
};

// Run the Actor and wait for it to finish
const run = await client.actor("honest_chainsaw/my-actor-3").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "contract": {
        "format": "csv",
        "delimiter": ",",
        "columns": [
            {
                "name": "sku",
                "type": "identifier",
                "required": True,
                "unique": True,
            },
            {
                "name": "quantite",
                "type": "integer",
                "required": True,
                "min": 0,
            },
        ],
    },
    "content": """sku,quantite
DEMO-001,3
DEMO-002,0
""",
}

# Run the Actor and wait for it to finish
run = client.actor("honest_chainsaw/my-actor-3").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "contract": {
    "format": "csv",
    "delimiter": ",",
    "columns": [
      {
        "name": "sku",
        "type": "identifier",
        "required": true,
        "unique": true
      },
      {
        "name": "quantite",
        "type": "integer",
        "required": true,
        "min": 0
      }
    ]
  },
  "content": "sku,quantite\\nDEMO-001,3\\nDEMO-002,0\\n"
}' |
apify call honest_chainsaw/my-actor-3 --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,honest_chainsaw/my-actor-3"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WMhHdruUFXReeYK88/builds/gae2QUhb1X0uo8BcW/openapi.json
