0.8.54 • Published 5 years ago

@topl/toy v0.8.54

Weekly downloads
97
License
MIT
Repository
-
Last release
5 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

5 years ago

0.8.53

5 years ago

0.8.52

5 years ago

0.8.51

5 years ago

0.8.50

5 years ago

0.8.49

5 years ago

0.8.48

5 years ago

0.8.47

5 years ago

0.8.46

5 years ago

0.8.45

5 years ago

0.8.44

5 years ago

0.8.43

5 years ago

0.8.42

5 years ago

0.8.41

5 years ago

0.8.40

5 years ago

0.8.39

5 years ago

0.8.38

5 years ago

0.8.37

5 years ago

0.8.36

5 years ago

0.8.35

5 years ago

0.8.34

5 years ago

0.8.33

5 years ago

0.8.32

5 years ago

0.8.31

5 years ago

0.8.30

5 years ago

0.8.29

5 years ago

0.8.28

5 years ago

0.8.27

5 years ago

0.8.26

5 years ago

0.8.25

5 years ago

0.8.24

5 years ago

0.8.23

5 years ago

0.8.22

5 years ago

0.8.21

5 years ago

0.8.20

5 years ago

0.8.19

5 years ago

0.8.18

5 years ago

0.8.17

5 years ago

0.8.16

5 years ago

0.8.15

5 years ago

0.8.14

5 years ago

0.8.13

5 years ago

0.8.12

5 years ago

0.8.11

5 years ago

0.8.10

5 years ago

0.8.9

5 years ago

0.8.8

5 years ago

0.8.7

5 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago