@bauke2112/invalidjsdeprecated

Invalid-JS 2.x.x is being developed! Check the branch invalid@next

Usage no npm install needed!

<script type="module">
  import bauke2112Invalidjs from 'https://cdn.skypack.dev/@bauke2112/invalidjs';
</script>

README

Invalid-JS

Invalid-JS 2.x.x is being developed! Check the branch invalid@next

Ivalid-JS is a Typescript-first schema validation library.

It is inspired by other validation libraries like Yup and Joi. Ivalid-JS tries to solve some problems regarding code duplication in such libraries, while exposing a simple and familiar function chaining API.

With Invalid-JS, it is also possible to create custom schemas and custom validation logic really easily.

Installation

To install Invalid-JS you can use one of the following commands, depending on the package manager you are using:

npm i @bauke2112/invalidjs --save
yarn add @bauke2112/invalidjs

Usage

Invalid-JS defines some function for creating schemas:

import { string, number, boolean, object } from '@bauke2112/invalidjs';

// Defining the schema
const schema = object().shape({
    name: string().required(),
    age: number().required(),
    isBrazilian: boolean().required(),
});

// Validating the schema
const [isValid, errors] = await schema.validate({
    name: 'Gustavo',
    age: 17,
    isBrazilian: true,
});

API