{"name":"joi","description":"Object schema validation","version":"6.10.0","repository":{"type":"git","url":"git://github.com/hapijs/joi"},"main":"lib/index.js","keywords":["hapi","schema","validation"],"engines":{"node":">=0.10.40","npm":">=2.0.0"},"dependencies":{"hoek":"2.x.x","topo":"1.x.x","isemail":"1.x.x","moment":"2.x.x"},"devDependencies":{"code":"1.x.x","lab":"6.x.x","markdown-toc":"0.11.x"},"scripts":{"test":"lab -t 100 -a code -L","test-cov-html":"lab -r html -o coverage.html -a code","toc":"node generate-readme-toc.js","version":"npm run toc && git add API.md"},"license":"BSD-3-Clause","readme":"![joi Logo](https://raw.github.com/hapijs/joi/master/images/joi.png)\n\nObject schema description language and validator for JavaScript objects.\n\n[![npm version](https://badge.fury.io/js/joi.svg)](http://badge.fury.io/js/joi)\n[![Build Status](https://secure.travis-ci.org/hapijs/joi.svg)](http://travis-ci.org/hapijs/joi)\n[![Dependencies Status](https://david-dm.org/hapijs/joi.svg)](https://david-dm.org/hapijs/joi)\n[![DevDependencies Status](https://david-dm.org/hapijs/joi/dev-status.svg)](https://david-dm.org/hapijs/joi#info=devDependencies)\n\n[![Join the chat at https://gitter.im/hapijs/joi](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hapijs/joi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\nLead Maintainer: [Nicolas Morel](https://github.com/marsup)\n\n# Example\n\n```javascript\nvar Joi = require('joi');\n\nvar schema = Joi.object().keys({\n    username: Joi.string().alphanum().min(3).max(30).required(),\n    password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/),\n    access_token: [Joi.string(), Joi.number()],\n    birthyear: Joi.number().integer().min(1900).max(2013),\n    email: Joi.string().email()\n}).with('username', 'birthyear').without('password', 'access_token');\n\nJoi.validate({ username: 'abc', birthyear: 1994 }, schema, function (err, value) { });  // err === null -> valid\n```\n\nThe above schema defines the following constraints:\n* `username`\n    * a required string\n    * must contain only alphanumeric characters\n    * at least 3 characters long but no more than 30\n    * must be accompanied by `birthyear`\n* `password`\n    * an optional string\n    * must satisfy the custom regex\n    * cannot appear together with `access_token`\n* `access_token`\n    * an optional, unconstrained string or number\n* `birthyear`\n    * an integer between 1900 and 2013\n* `email`\n    * a valid email address string\n\n# Usage\n\nUsage is a two steps process. First, a schema is constructed using the provided types and constraints:\n\n```javascript\nvar schema = {\n    a: Joi.string()\n};\n```\n\nNote that **joi** schema objects are immutable which means every additional rule added (e.g. `.min(5)`) will return a\nnew schema object.\n\nThen the value is validated against the schema:\n\n```javascript\nJoi.validate({ a: 'a string' }, schema, function (err, value) { });\n```\n\nIf the value is valid, `null` is returned, otherwise an `Error` object.\n\nThe schema can be a plain JavaScript object where every key is assigned a **joi** type, or it can be a **joi** type directly:\n\n```javascript\nvar schema = Joi.string().min(10);\n```\n\nIf the schema is a **joi** type, the `schema.validate(value, callback)` can be called directly on the type. When passing a non-type schema object,\nthe module converts it internally to an object() type equivalent to:\n\n```javascript\nvar schema = Joi.object().keys({\n    a: Joi.string()\n});\n```\n\nWhen validating a schema:\n\n* Keys are optional by default.\n* Strings are utf-8 encoded by default.\n* Rules are defined in an additive fashion and evaluated in order after whitelist and blacklist checks.\n\n# API\nSee the [API Reference](API.md).","readmeFilename":"README.md","bugs":{"url":"https://github.com/hapijs/joi/issues"},"homepage":"https://github.com/hapijs/joi","_id":"joi@6.10.0","_shasum":"4e7a99d6e0b3f783ccb4120e1f0f5f9d5dba6ff3","_from":"https://registry.npmjs.org/joi/-/joi-6.10.0.tgz","_resolved":"https://registry.npmjs.org/joi/-/joi-6.10.0.tgz"}