# raml-typesystem

> [![Build Status](https://travis-ci.org/raml-org/raml-typesystem.svg?branch=master)](https://travis-ci.org/raml-org/raml-typesystem) [![Greenkeeper badge](https://badges.greenkeeper.io/raml-org/raml-typesystem.svg)](https://greenkeeper.io/)

Latest version **0.0.96** (published 2020-04-07) · Apache-2.0 license · 0 weekly downloads

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

## Install

```sh
npm install raml-typesystem
pnpm add raml-typesystem
yarn add raml-typesystem
bun add raml-typesystem
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.96 |
| Published | 2020-04-07 |
| First published | 2016-02-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 3.7 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 15 |
| Maintainers | denis.denisenko, petrochenko-pavel-a |
| Keywords | raml, typesystem |

## Links

- npm: https://www.npmjs.com/package/raml-typesystem
- Repository: https://github.com/raml-org/raml-typesystem
- Issues: https://github.com/raml-org/raml-typesystem/issues
- npm.io page: https://npm.io/package/raml-typesystem

## Dependencies (11)

- [xml2js](https://npm.io/package/xml2js.md) ^0.4.23
- [lrucache](https://npm.io/package/lrucache.md) 1.0.3
- [underscore](https://npm.io/package/underscore.md) ^1.10.2
- [escape-html](https://npm.io/package/escape-html.md) 1.0.3
- [json-to-ast](https://npm.io/package/json-to-ast.md) 2.0.0-alpha1.3
- [bignumber.js](https://npm.io/package/bignumber.js.md) 9.0.0
- [xmldom-alpha](https://npm.io/package/xmldom-alpha.md) ^0.1.28
- [date-and-time](https://npm.io/package/date-and-time.md) ^0.11.1
- [raml-xml-validation](https://npm.io/package/raml-xml-validation.md) 0.0.15
- [raml-json-validation](https://npm.io/package/raml-json-validation.md) 0.0.18
- [json-schema-compatibility](https://npm.io/package/json-schema-compatibility.md) 1.1.0

## Recent versions

- 0.0.96 (latest) — 2020-04-07
- 0.0.29-rc2 (beta) — 2016-05-06
- 0.0.95 — 2020-03-10
- 0.0.94 — 2019-10-24
- 0.0.93 — 2019-07-25
- 0.0.92 — 2019-07-03
- 0.0.91 — 2019-03-28
- 0.0.90 — 2018-09-25
- 0.0.89 — 2018-08-28
- 0.0.88 — 2018-08-21
- 0.0.87 — 2018-07-12
- 0.0.86 — 2018-05-17
- 0.0.85 — 2018-04-17
- 0.0.84 — 2018-03-06
- 0.0.83 — 2018-01-24
- … 80 more at https://npm.io/package/raml-typesystem/versions

## README

# RAML Data Type System

[![Build Status](https://travis-ci.org/raml-org/raml-typesystem.svg?branch=master)](https://travis-ci.org/raml-org/raml-typesystem) [![Greenkeeper badge](https://badges.greenkeeper.io/raml-org/raml-typesystem.svg)](https://greenkeeper.io/)

This module contains a lightweight implementation of the type system that was introduced with [RAML 1.0](http://raml.org).

It allows you to to parse, validate , modify RAML types, as well as store them back to JSON.

## Installation

```
npm install raml-typesystem --save
```

## Usage

Parsing and validating a single type:

```js
import ts = require("raml-typesystem")

var personType = ts.loadType( {
    type: "string[]",
    minItems:3,
    maxItems:2
})

var isValid = personType.validateType();
```

Parsing and validating a `types` collection:

```js
import ts = require("raml-typesystem")

var typeCollection = ts.loadTypeCollection({
    types: {
        Person: {
            type: "object",
            properties:{
                kind: "string"
            }
        },
        Man: {
            type: "Person",
            discriminator: "kind"
        }
    }
})
var isValid = typeCollection.getType("Person").validateType()
```


Validating object against type:

```js
import ts = require("raml-typesystem")

var typeCollection = ts.loadTypeCollection({
    types: {
        Person: {
            type: "object",
            properties:{
                kind: "string"
            }
        },
        Man: {
            type: "Person",
            discriminator: "kind"
        }
    }
})
var isValid = typeCollection.getType("Person").validate({dd: true})
```

## Contribute

The raml-typesystem repo is an open source project and any contribution is always welcome. Please follow these simple steps when contributing to this project:

1. Check for open issues or open a fresh issue to start a discussion around an idea or a bug.
2. Fork the repository on Github and make your changes on the develop branch (or branch off of it).
3. Send a pull request (with the develop branch as the target).
4. One of the main contributor or admin will review the PR and merge.

A big thank you goes out to everyone who helped with the project, the contributors and everyone who took the time to report issues and give feedback.

You can also directly get in touch with us. Simply send us an email to: info@raml.org

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