# Getting Started

`TypeScript` ready schema validator

[![](https://github.com/rapidom/schema/workflows/Test/badge.svg)](https://github.com/rapidom/schema/actions) [![](https://codecov.io/gh/rapidom/schema/branch/main/graph/badge.svg)](https://codecov.io/gh/rapidom/schema) [![](https://img.shields.io/npm/v/@rapidom/schema.svg)](https://www.npmjs.com/package/@rapidom/schema) [![](https://img.shields.io/bundlephobia/min/@rapidom/schema.svg)](https://www.npmjs.com/package/@rapidom/schema) [![](https://img.shields.io/bundlephobia/minzip/@rapidom/schema.svg)](https://www.npmjs.com/package/@rapidom/schema) [![](https://img.shields.io/npm/dm/@rapidom/schema.svg)](https://www.npmjs.com/package/@rapidom/schema) [![](https://img.shields.io/npm/dt/@rapidom/schema.svg)](https://www.npmjs.com/package/@rapidom/schema) [![](https://david-dm.org/rapidom/schema.svg)](https://david-dm.org/rapidom/schema) [![](https://img.shields.io/github/issues-raw/rapidom/schema.svg)](https://github.com/rapidom/schema/issues?q=is%3Aopen+is%3Aissue) [![](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/rapidom/schema/pulls) [![](https://img.shields.io/github/license/rapidom/schema.svg)](https://github.com/rapidom/schema/blob/main/LICENSE)

## Table of Content

* [Getting Started](#getting-started)
  * [Installation](#installation)
  * [Usage](#usage)
* [Versioning](#versioning)
* [Authors](#authors)
* [License](#license)

## Getting Started

### Installation

NPM / GitHub Packages:

```
npm i @rapidom/schema
```

Yarn:

```
yarn add @rapidom/schema
```

### Usage

```typescript
import Schema from "@rapidom/schema";

const schema = {
  username: Schema.string()
    .alphanum()
    .required(),
  name: Schema.object().keys({
    first: Schema.string()
      .min(3)
      .required(),
    last: Schema.string().min(3),
  }).required(),
  datetime: Schema.date().default(Date.now),
};

try {
  const result = Schema.object().keys(schema).validate(value);
} catch (error) {
  // your error handler
}
```

## Authors

* **Ardalan Amini** - *Core Maintainer* - [@ardalanamini](https://github.com/ardalanamini)

See also the list of [contributors](https://github.com/rapidom/schema/contributors) who participated in this project.

## Versioning

We use [SemVer](http://semver.org) for versioning. For the versions available, see the [releases](https://github.com/rapidom/schema/releases).

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/rapidom/schema/blob/main/LICENSE) file for details
