# 18xx-schemas

> Schema files for 18xx-maker game and tile files

Latest version **0.4.1** (published 2020-05-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install 18xx-schemas
pnpm add 18xx-schemas
yarn add 18xx-schemas
bun add 18xx-schemas
```

Provides the command `18xx-schemas`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2020-05-02 |
| First published | 2020-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 32 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christopher Giroir |
| Maintainers | kelsin |

## Links

- npm: https://www.npmjs.com/package/18xx-schemas
- Repository: https://github.com/18xx-maker/18xx-schemas
- npm.io page: https://npm.io/package/18xx-schemas

## Dependencies (5)

- [ajv](https://npm.io/package/ajv.md) ^6.12.2
- [glob](https://npm.io/package/glob.md) ^7.1.6
- [chalk](https://npm.io/package/chalk.md) ^4.0.0
- [ramda](https://npm.io/package/ramda.md) ^0.27.0
- [commander](https://npm.io/package/commander.md) ^5.1.0

## Recent versions

- 0.4.1 (latest) — 2020-05-02
- 0.4.0 — 2020-05-01
- 0.3.0 — 2020-05-01
- 0.2.0 — 2020-05-01
- 0.1.0 — 2020-05-01
- 0.0.1 — 2020-05-01

## README

# 18xx-schemas

This repository contains the game and tile schemas that 18xx-maker uses for it's
game files.

# CLI Usage

Install this package gives you a `18xx-schemas` binary that takes in any number
of globs and validates each file it can find. If a file doesn't exist it just
ignores it. It then pretty prints the validation output using ansi colors on the
terminal.

```shell
# Validate some files
18xx-schemas games/*.json tiles/**/*.json config.json

# Display all options
18xx-schemas -h

# Output version
18xx-schemas -v
```

Be warned that if you pass a json that doesn't conform to any of the 18xx-maker
json schemas it will be validated against the tiles schema.

# Programatic Usage

You can use this package in your javascript to validate game files using two
functions:

```javascript
const validate = require("18xx-schemas");

// If you have some json you can validate it directly:
const json = require("18Awesome.json");
let result = validate(json);

// If you want to include data in the result you can optionally pass the file used:
result = validate(json, "18Awesome.json");

// Or you can use a helper which will load the json from a file:
result = validate.file("18Awesome.json");

// In either case you get a result object that looks like:
// {
//   valid: true if validation succeeded (boolean)
//   id: the schema id of the schema used to validate this file (string)
//   file: the filename of the file loaded (not available on validate unless you pass it in) (string)
//   error: error message if we had trouble reading the passed in file (only on validate.file) (string)
//   validationErrors: error object from ajv which has all validation errors in it (object)
// }
```

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