pizza-validator

1.0.2 • Public • Published

Pizza-Validator

A package to determine if objects are valid pizzas!

Installation

The easiest way to install pizza-validator is from npm:

npm install pizza-validator

Interface

validatePizza(input) is the main interface to the library. Theinput parameter is an object of any kind. The return value will be a discriminated union type object with the fields:

isPizza errors only if isPizza is false (providing some form of information on why the given object is not a pizza) pizza only if isPizza is true, which should be our same pizza object but with the type known.

import { validatePizza } from 'pizza-validator';
const pizza : object = {
        size: 12,
        crust: 'normal',
        isDeepDish: true,
        toppings: ['screws'],
    };
    const result = validatePizza(pizza);

Command line interface

ts-node pizza-validator test-pizza.json can be used to parse a json from the command line (assuming you have a json named test-pizza).

Readme

Keywords

Package Sidebar

Install

npm i pizza-validator

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

17.5 kB

Total Files

12

Last publish

Collaborators

  • kris1