{"bugs":{"url":"https://github.com/hapijs/joi/issues"},"dist":{"shasum":"197e06edbd90436150f7f02154a83d0a82753188","tarball":"https://registry.npmjs.org/@hapi/joi/-/joi-14.5.0.tgz","fileCount":29,"integrity":"sha512-q8oNlQWQpN14j6lMkaQqVdG8km+Ni32ZeuJ+sSOB+5a5VsIY6KVpPvdoMU/XKyAS7P7qP0TgM9fFGC2d8dB6hA==","signatures":[{"sig":"MEUCIHnqH09WudmfglqMgH7Wj/ZSnSpX2aK17RvwbfQITGu0AiEA9Egew1+FDG2QbXASzNDYeBjijd8My1UaVfVR6W/eheU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":191925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdDuG3CRA9TVsSAnZWagAA7egP/36UZxQ/ZG9CID4LRujf\nPVfmsW6/0U7NpSpTVmNMWURp7nC86Asp2fUy5YB7zke/3iZ++qNClUaIQYCa\nWUwFcFqnfbL80YvdZDqMPgjhhBL66sw4BOfby42UUtvQAQHdWDe/JrBtNS4J\nlf3REfRcCZZOpt2bBXOQKT+RS9zqDXywiJHcIj1Jl49Kl1wrIvtxsNTIDSaW\nbNzMJVRYaSHjW5ICjhqWCWrVxtX+pU0AA1IyB0lyyi4kzryvenV2gnevcZbr\nllN4I/v/nhAX9xVw9pShe+uwOyGi/nwe6CKJ9IGYLbqdN+QT8spYgMjSoLPE\nwMjrcKdBHE8n+ls0A/o3BkawrcAD9oEDCiFHUwwYzhqZwhWPOZTdMO5gmWuL\nSNWwNmRCkaXZvRMVwVOUODliu2Nrxp9Nx9v4t4iU71ImpHtdMPSY8xrlo+gP\nvnYhyvcqLdQYQzaIxpisEJbGk9+gNrVHFvSzXzNMiyBkd90oG6m/8yHvp4Q0\nBd0hV0GF56JAvv3c2/iunqMT9vN4T/uOPDeMH5tUuVVtVSVon1U+4CxqelsY\nceZUxy4nYNqNq6XOt6w56M/7BI4y9oP4c/gWmlT8ODmXhwf6raV1gITsDuHk\nYWMwC9w++sd07iGekXfHGbkA3NUP0O50BVPM8fXQXH/xu49MTVQUEndc8vQ8\nu2VD\r\n=Ldnf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","name":"@hapi/joi","readme":"# joi\n\nObject schema description language and validator for JavaScript objects.\n\n[![Build Status](https://travis-ci.org/hapijs/joi.svg?branch=master)](https://travis-ci.org/hapijs/joi)\n\nLead Maintainer: [Nicolas Morel](https://github.com/marsup)\n\n# Introduction\n\nImagine you run facebook and you want visitors to sign up on the website with real names and not something like `l337_p@nda` in the first name field. How would you define the limitations of what can be inputted and validate it against the set rules?\n\nThis is joi, joi allows you to create *blueprints* or *schemas* for JavaScript objects (an object that stores information) to ensure *validation* of key information.\n\n# API\nSee the detailed [API Reference](/blob/v14.5.0/API.md).\n\n# Example\n\n```javascript\nconst Joi = require('joi');\n\nconst 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({ minDomainAtoms: 2 })\n}).with('username', 'birthyear').without('password', 'access_token');\n\n// Return result.\nconst result = Joi.validate({ username: 'abc', birthyear: 1994 }, schema);\n// result.error === null -> valid\n\n// You can also pass a callback which will be called synchronously with the validation result.\nJoi.validate({ username: 'abc', birthyear: 1994 }, schema, function (err, value) { });  // err === null -> valid\n\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    * must have two domain parts e.g. `example.com`\n\n# Usage\n\nUsage is a two steps process. First, a schema is constructed using the provided types and constraints:\n\n```javascript\nconst 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\nSecond, the value is validated against the defined schema:\n\n```javascript\nconst {error, value} = Joi.validate({ a: 'a string' }, schema);\n\n// or\n\nJoi.validate({ a: 'a string' }, schema, function (error, value) { });\n```\n\nIf the input is valid, then the `error` will be `null`, otherwise it will be an `Error` object providing more information.\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\nconst 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\nconst schema = Joi.object().keys({\n    a: Joi.string()\n});\n```\n\nWhen validating a schema:\n\n* Values (or keys in case of objects) are optional by default.\n\n    ```javascript\n    Joi.validate(undefined, Joi.string()); // validates fine\n    ```\n\n    To disallow this behavior, you can either set the schema as `required()`, or set `presence` to `\"required\"` when passing `options`:\n\n    ```javascript\n    Joi.validate(undefined, Joi.string().required());\n    // or\n    Joi.validate(undefined, Joi.string(), /* options */ { presence: \"required\" });\n    ```\n\n* Strings are utf-8 encoded by default.\n* Rules are defined in an additive fashion and evaluated in order, first the inclusive rules, then the exclusive rules.\n\n# Browsers\n\nJoi doesn't directly support browsers, but you could use [joi-browser](https://github.com/jeffbski/joi-browser) for an ES5 build of Joi that works in browsers, or as a source of inspiration for your own builds.\n","gitHead":"043cde6a8c44d6132ee4a95e4a12bf58ec274e04","license":"BSD-3-Clause","scripts":{"toc":"hapitoc && node docs/check-errors-list.js","test":"lab -t 100 -a @hapi/code -L","version":"npm run toc && git add API.md README.md","test-debug":"lab -a @hapi/code","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"_npmUser":{"name":"hueniverse","email":"eran@hammer.io"},"homepage":"https://github.com/hapijs/joi#readme","keywords":["schema","validation"],"deprecated":"Switch to 'npm install joi'","repository":{"url":"git://github.com/hapijs/joi.git","type":"git"},"_npmVersion":"6.9.0","description":"Object schema validation","directories":{},"maintainers":[{"name":"hueniverse","email":"eran@hammer.io"},{"name":"marsup","email":"nicolas@morel.io"},{"name":"wyatt","email":"wpreul@gmail.com"}],"_nodeVersion":"12.2.0","dependencies":{"isemail":"3.x.x","@hapi/hoek":"6.x.x","@hapi/topo":"3.x.x","@hapi/marker":"1.x.x"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"hapitoc":"1.x.x","@hapi/lab":"18.x.x","@hapi/code":"5.x.x"},"_npmOperationalInternal":{"tmp":"tmp/joi_14.5.0_1561256373734_0.4568625923653242","host":"s3://npm-registry-packages"},"_id":"@hapi/joi@14.5.0","version":"14.5.0"}