Getting Started
TypeScript ready schema validator

Table of Content

Getting Started

Installation

NPM / GitHub Packages:
1
npm i @rapidom/schema
Copied!
Yarn:
1
yarn add @rapidom/schema
Copied!

Usage

1
import Schema from "@rapidom/schema";
2
​
3
const schema = {
4
username: Schema.string()
5
.alphanum()
6
.required(),
7
name: Schema.object().keys({
8
first: Schema.string()
9
.min(3)
10
.required(),
11
last: Schema.string().min(3),
12
}).required(),
13
datetime: Schema.date().default(Date.now),
14
};
15
​
16
try {
17
const result = Schema.object().keys(schema).validate(value);
18
} catch (error) {
19
// your error handler
20
}
Copied!

Authors

See also the list of contributors who participated in this project.

Versioning

We use SemVer for versioning. For the versions available, see the releases.

License

This project is licensed under the MIT License - see the LICENSE file for details
Last modified 4mo ago