# table-validator

> Table Validator for CSV

Latest version **0.0.5** (published 2023-12-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install table-validator
pnpm add table-validator
yarn add table-validator
bun add table-validator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-12-23 |
| First published | 2023-12-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 215.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Koichi Ishida |
| Maintainers | wapa5pow |
| Keywords | csv, content, validator, schema |

## Links

- npm: https://www.npmjs.com/package/table-validator
- Repository: https://github.com/wapa5pow/table-validator
- Homepage: https://github.com/wapa5pow/table-validator#readme
- Issues: https://github.com/wapa5pow/table-validator/issues
- npm.io page: https://npm.io/package/table-validator

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ^8.12.0
- [yaml](https://npm.io/package/yaml.md) ^2.3.4
- [papaparse](https://npm.io/package/papaparse.md) ^5.4.1

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2023-12-23
- 0.0.4 — 2023-12-19
- 0.0.3 — 2023-12-19
- 0.0.2 — 2023-12-19
- 0.0.1 — 2023-12-19

## README

# Table Validator

[**Online Demo**](https://wapa5pow.github.io/table-validator/)

[table-validator](https://www.npmjs.com/package/table-validator) is an table(like csv) validator library in Typescript.
With yaml schema definition, it validates an table and throw error if content does not match the schema.
It implements features inspired by "[csv-validator](https://github.com/digital-preservation/csv-validator)".

## Installation

```bash
npm install table-validator
```

## API

```typescript
const schema = convertToSchema(fs.readFileSync("/path/to/yaml", "utf8"));
const table = convertToTable(fs.readFileSync("/path/to/csv", "utf8"), {
  header: true,
});
const validator = new Validator();
const errors = validator.validate(table, schema);
if (errors.length === 0) {
  console.log("No error");
} else {
  for (const error of errors) {
    console.log(`${error}`);
  }
}
```

## List of available rules

Non combinatorial expressions

- notEmpty: `notEmpty`
- empty: `empty`
- is: `is("Japan")`
- not: `not("Tokyo")`
- unique: `unique`
- range: `range(10,20)`
- length: `length(2,10)`
- regex: `regex("[bcm]at")`
- integer: `integer`
- float: `float`
- any: `any("a","b")`

Combinatorial expression

- or: `is("Japan") or is("France")`
- and: `length(2) and range(10,20)`

Others

- parentheses: `(length(2) and range(10,20)) or empty`

## Example

### React example

```bash
npm run react
```

### CLI example

```bash
npm run cli
```

---
_Source: https://npm.io/package/table-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
