Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

foxifyjs/schema

Repository files navigation

schema

TypeScript ready object schema validation

NPM Version TypeScript Version Tested With Jest Pull Requests License Build Status Coverage Status Package Quality Dependencies Status NPM Total Downloads NPM Monthly Downloads Open Issues Closed Issues known vulnerabilities Github Stars Github Forks

Table of Content

Getting Started

Installation

NPM:

npm i @foxify/schema

Yarn:

yarn add @foxify/schema

Github Packages:

npm i @foxifyjs/schema

Usage

import Schema from "@foxify/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
}

for more details read the documents

Sponsors

Support this project by becoming a sponsor. Your logo will show up here. [Become a sponsor]

Sponsors

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