Neighborly Package Megalodon
Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

@foxify/schema

1.2.0 • Public • Published

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

Prerequisites

Installation

npm i -s @foxify/schema

Usage

const Schema = require("@foxify/schema");
 
const schema = {
  username: Schema.string()
    .alphanum()
    .required(),
  name: {
    first: Schema.string()
      .min(3)
      .required(),
    last: Schema.string().min(3),
  }, // since "name" has a required field, "name" itself would become required too
  datetime: Schema.date().default(Date.now),
};
 
Schema.validate(schema, value);
// returns -> { errors, value }
// error -> null : you're good to go
// error -> { [path: string]: string[] } : you have a problem

for more details see the documents

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

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

License

This project is licensed under the MIT License - see the LICENSE file for details

Support

If my work helps you, please consider

Buy Me A Coffee Become A Patron

Install

npm i @foxify/schema

DownloadsWeekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

53.5 kB

Total Files

31

Last publish

Collaborators

  • avatar