0.8.54 • Published 6 years ago

@topl/toy v0.8.54

Weekly downloads
97
License
MIT
Repository
-
Last release
6 years ago

🦜 toy

garth

Toy is a language for validating user input. Like JSON, its syntax is a subset of JavaScript.

array().items(string(), number()).validate([1, 1, 2, 3, 5, "eureka!"])

Toy is based upon (a partial clone but not a fork of) Joi

installation

npm install @topl/toy

usage

import { string } from "@topl/toy";

// Validate you a string:
const clean = string().validate(dirty);

If you prefer, you can import the namespace:

import * as toy from "@topl/toy";

const clean = toy.string().validate(dirty);

It is also possible to use toy with CommonJS:

const toy = require("@topl/toy"); // and so on
const { string } = require("@topl/toy"); // also possible

note

This is a clone of joi that is designed to be slightly lower-level. It lacks some of the higher-level validations joi has, notably ones for email and uuid. Instead, it adds a pair of general purpose operators, .must() and .derive(), to which the user can pass along a lambda. For instance, email validation can be accomplished like this:

const { string } = require("@topl/toy");
const isEmail = require('isemail');

const validEmail = string().must(isEmail).validate(input);

The intent is to keep toy small, but provide a common api to support all the use-cases.

api

See API

license

See LICENSE

0.8.54

6 years ago

0.8.53

6 years ago

0.8.52

6 years ago

0.8.51

6 years ago

0.8.50

6 years ago

0.8.49

6 years ago

0.8.48

6 years ago

0.8.47

6 years ago

0.8.46

6 years ago

0.8.45

6 years ago

0.8.44

6 years ago

0.8.43

6 years ago

0.8.42

6 years ago

0.8.41

6 years ago

0.8.40

6 years ago

0.8.39

6 years ago

0.8.38

6 years ago

0.8.37

6 years ago

0.8.36

6 years ago

0.8.35

6 years ago

0.8.34

6 years ago

0.8.33

6 years ago

0.8.32

6 years ago

0.8.31

6 years ago

0.8.30

6 years ago

0.8.29

6 years ago

0.8.28

6 years ago

0.8.27

6 years ago

0.8.26

6 years ago

0.8.25

6 years ago

0.8.24

6 years ago

0.8.23

6 years ago

0.8.22

6 years ago

0.8.21

6 years ago

0.8.20

6 years ago

0.8.19

6 years ago

0.8.18

6 years ago

0.8.17

6 years ago

0.8.16

6 years ago

0.8.15

6 years ago

0.8.14

6 years ago

0.8.13

6 years ago

0.8.12

6 years ago

0.8.11

6 years ago

0.8.10

6 years ago

0.8.9

6 years ago

0.8.8

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.4

6 years ago

0.8.3

6 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago