# Data Validator

Validate pasted CSV or JSON rows against field rules — required, unique, type, range, length, regex, enum — and list every violation. Free, runs in your browser.

## Run it

- **CLI:** `gizza tool data-validator "email,age,plan
a@b.com,34,pro
bad-email,200,gold" 'rules=email:required
email:type=email
age:type=int
age:max=120
plan:enum=free|pro|team'`
- **Web:** https://gizza.ai/tools/data-validator/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/data-validator/tool.json

## Inputs

- `data` — CSV or JSON rows _(field)_
- `rules` — Rules (one per line, field:rule) _(field)_
- `input_format` — Read data as _(field)_
- `header` — CSV has a header row _(field)_
- `delimiter` — CSV delimiter _(field)_
- `max_issues` — Max violations to list _(field)_
- `format` — Output _(field)_

## Output

- Report (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — CSV or JSON rows
- `rules` — Rules (one per line, field:rule)
- `input_format` — Read data as
- `header` — CSV has a header row
- `delimiter` — CSV delimiter
- `max_issues` — Max violations to list
- `format` — Output

Example: `https://gizza.ai/tools/data-validator/?data=email%2Cage%2Cplan%0Aa%40b.com%2C34%2Cpro%0Abad-email%2C200%2Cgold&rules=email%3Arequired%0Aemail%3Atype%3Demail%0Aage%3Atype%3Dint%0Aage%3Amax%3D120%0Aplan%3Aenum%3Dfree%7Cpro%7Cteam&input_format=auto&header=true&delimiter=auto&max_issues=50&format=text`

---

## About this tool

Data Validator checks pasted **CSV** or **JSON** rows against the field rules you
write. It is useful before imports, migrations, mail merges, API uploads, or any
other step where bad rows are expensive to discover later.

Write one rule per line:

```text
email:required
email:type=email
age:type=int
age:min=18
age:max=120
plan:enum=free|pro|team
id:unique
```

The report lists every violation with its record, physical line, field, offending
value, broken rule, and a short explanation. The tool is report-only: it never
modifies your data and it runs locally in your browser.

### Worked example

Input CSV:

```csv
email,age,plan
a@b.com,34,pro
bad-email,200,gold
```

Rules:

```text
email:required
email:type=email
age:type=int
age:min=0
age:max=120
plan:enum=free|pro|team
```

Output highlights three violations on record 2: the invalid email, age above
`120`, and plan outside the allowed enum.

### Options and limits

- **Read data as** — `auto`, `csv`, or `json`. Auto treats values starting with
  `[` or `{` as JSON and everything else as CSV.
- **CSV delimiter** — auto-detects comma, tab, semicolon, and pipe.
- **CSV has a header row** — on by default. If you turn it off, refer to columns
  by 1-based index (`1:required`, `2:type=int`).
- **Max violations to list** — caps how many details are shown while still
  reporting the total count. The accepted range is `1`–`1000`.
- JSON input can be an array of objects, a single object, or JSON Lines / NDJSON.

## FAQ

<details>
<summary>Which validation rules are supported?</summary>

Use `required`, `unique`, `type=int|float|bool|date|email|url`, `min` / `max` for
numeric ranges, `minlen` / `maxlen` for character counts, `regex=...`, and
`enum=a|b|c`. You can also write bare type shorthand such as `age:int`.

</details>

<details>
<summary>Do optional blank values fail type, range, regex, or enum rules?</summary>

No. Every rule except `required` is skipped for a blank or missing value. Combine
rules such as `email:required` and `email:type=email` when a field must be present
and must match a format.

</details>

<details>
<summary>Can I validate JSON as well as CSV?</summary>

Yes. JSON can be an array of objects, one object, or JSON Lines. Field names come
from object keys. CSV can use header names, or 1-based column numbers when the
header option is off.

</details>

<details>
<summary>Are regex rules anchored automatically?</summary>

No. Regex rules use the pattern you provide. Add `^` and `$` yourself when the
whole value must match, for example `email:regex=^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$`.

</details>

## Related tools

- [CSV Column Type Validator](https://gizza.ai/tools/csv-column-type-validator/): Validate CSV columns against declared types like int, float, bool, date, and enum, with row/line reports for every offending cell.
- [Validate CSV structure](https://gizza.ai/tools/csv-structure-validator/): Validate CSV structure online: find ragged rows, inconsistent column counts, unclosed quotes, and stray delimiters with line numbers. Free, private, in-browser.
- [Amazon Order Analyzer](https://gizza.ai/tools/amazon-order-analyzer/): Paste an Amazon order-history CSV export to summarize total spend by month, top items, and category breakdowns. Browser-only, private, with Markdown or JSON output.
- [Avro to JSON Converter](https://gizza.ai/tools/avro-to-json/): Decode Apache Avro Object Container Files (.avro / OCF) to JSON, NDJSON, or the embedded schema — no .avsc needed, free and private in your browser.
- [Reconcile bank statement and ledger CSVs](https://gizza.ai/tools/bank-statement-reconcile/): Match bank-statement CSV rows to ledger rows by date, signed amount, and fuzzy memo similarity, with unmatched and suggested matches.
