Getting Started
TypeScript ready schema validator
Table of Content
Getting Started
Installation
NPM / GitHub Packages:
npm i @rapidom/schemaYarn:
yarn add @rapidom/schemaUsage
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
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 updated
Was this helpful?