1.0.2 • Published 3 months ago

pizza-validator v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

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

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago