npm.io
1.0.2 • Published 2 years agoCLI

pizza-validator

Licence
ISC
Version
1.0.2
Deps
2
Size
17 kB
Vulns
0
Weekly
0

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).

Keywords