{"name":"mschema","version":"0.5.2","keywords":["schema","mschema","validator","json","json-schema"],"description":"A schema language for defining the structure of JSON data","repository":"","main":"index.js","directories":{"example":"examples","test":"tap test/"},"dependencies":{},"devDependencies":{"tap":"~0.4.4"},"scripts":{"test":"tap test/*.js"},"author":{"name":"Marak Squires","email":"support@marak.com"},"license":"MIT","gitHead":"97f335723c70d5d99462fe608ddc8f03a2c6947a","_id":"mschema@0.5.2","dist":{"shasum":"fca2c868df857d26d7e65cefa98b3d7d2a5847b0","tarball":"http://registry-npm.ywwl.com/mschema/download/mschema-0.5.2.tgz","integrity":"sha512-UotcbPkiEaMtVJeFxeM2OChORXMMLykLS1cNJyx1pBiJTBo0Hhz8jgJGFR+LZeDn7pqsI0lEzybPbzKX/l3Wug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDocp8w7CVBTC0DD+GxUdfSO4LwjQv4l2SyPCbxlrMl4QIgeTXb1J8CjBp8ZSBXQHoZfMasvD1GTFVuGJrNcRFWKQE="}],"size":11646,"noattachment":false,"key":"/mschema/-/mschema-0.5.2.tgz"},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"marak","email":"marak.squires@gmail.com"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"readme":"# mschema\n\n<img src=\"https://travis-ci.org/mschema/mschema.svg?branch=master\"/>\n\nA concise schema language for describing the structure of JSON data\n\n## Features\n\n - simple intuitive syntax\n - schemas are JSON\n - schemas can be linked using `require()`\n\n### See Also\n\n - mschema-rpc(http://github.com/mschema/mschema-rpc)\n\n### Install with npm\n\n     npm install mschema\n\n### Install with [component](https://github.com/component/component)\n\n    component install mschema/mschema\n\n## Example\n\n*see '/test' folder for alternate syntax and examples*\n\n```js\n\nvar mschema = require('mschema');\n\nvar user = {\n  \"name\": {\n    \"type\": \"string\",\n    \"minLength\": 5,\n    \"maxLength\": 20\n  },\n  \"password\": {\n    \"type\": \"string\",\n    \"minLength\": 8,\n    \"maxLength\": 64\n  },\n  \"email\": \"string\"\n}\n\nvar data = {\n  \"name\": \"Marak\",\n  \"password\": \"atleasteight\",\n  \"email\": \"foo@bar.com\"\n}\n\n// validates true\nvar result = mschema.validate(data, user);\nconsole.log(result);\n\nvar data = {\n  \"name\": \"M\",\n  \"password\": \"1234\",\n  \"email\": \"foo@bar.com\"\n}\n\n// validates false with errors\nvar result = mschema.validate(data, user);\nconsole.log(result);\n\nvar blog = {\n  \"name\": \"string\",\n  \"posts\": [{\"title\": { \"type\": \"string\", \"maxLength\": 15 }, \"author\": \"string\", \"content\": \"string\" }]\n};\n\nvar data = {\n  \"name\": \"My blog\",\n  \"posts\": [{\n    \"title\": \"An example blog post\",\n    \"author\": \"Marak\",\n    \"content\": \"This is an example blog post\"\n  }]\n};\n\n// validates true\nvar result = mschema.validate(data, blog);\nconsole.log(result);\n```\n\n# API\n\n### mschema.validate(data, schema)\n\n### data\nthe data to be validated\n\n### schema\nthe schema to validate the data against\n\n# Usage\n\nsee: `/examples` and `/test` folders for additional usage\n\n### Type assignment as string\n\n```json\n {\n   \"name\": \"string\",\n   \"age\": \"number\",\n   \"address\": \"object\",\n   \"isActive\": \"boolean\"\n }\n```\n\n### Type assignment as an object literal\n\n```json\n{ \n  \"id\": {\n    \"type\": \"string\",\n    \"minLength\": 5,\n    \"maxLength\": 10\n  }\n}\n```\n\n### Nesting Types\n\n```json\n{ \n  \"name\": \"string\",\n  \"password\": \"string\",\n  \"address\": {\n    \"street\": \"string\",\n    \"city\": \"string\",\n    \"country\": \"string\"\n  }\n}\n```\n\n## Typed arrays\n\n### Generic types\n\n```json\n{ \"posts\": [\"string\"] }\n```\n\n### Typed with constraints\n\n```json\n{ \"posts\": [{ \"type\": \"string\", \"minLength\": 5, \"maxLength\": 10 }] }\n```\n\n### Array of objects\n\n```js\n{ \"posts\": [{\n     \"title\": {\n       \"type\": \"string\",\n       \"minLength\": 3,\n       \"maxLength\": 15\n     },\n     \"content\": {\n       \"type\": \"string\",\n       \"minLength\": 3,\n       \"maxLength\": 15\n     }\n }]\n```\n\n## Linking Schemas\n\nSchemas can be linked together using JS\n\n```js\n\nvar address = {\n  \"street\": \"string\",\n  \"city\": \"string\",\n  \"zipcode\": \"string\"\n}\n\nvar user = {\n  \"name\": \"string\",\n  \"age\": \"number\",\n  \"address\": address\n\nvar data = {\n  \"name\": \"Marak\",\n  \"age\": 42,\n  \"address\": {\n    \"street\": \"123 elm street\",\n    \"city\": \"Canada\",\n    \"zipcode\": \"12345-01\"\n  }\n};\n\nvar validate = mschema.validate(data, user); \n\n// validates to true\n\n```\n\n## Relation to JSON-Schema\n\nJSON-Schema was designed to the specifications of [XML-Schema](http://en.wikipedia.org/wiki/XML_schema), which was designed to express [Document Type Definitions](http://en.wikipedia.org/wiki/Document_Type_Definition).\n\nSimply put: JSON-Schema has a lot of functionality that most developers don't need or want. The complexity of JSON-Schema makes it difficult to use and hard to build tools for.\n\n### Key differences between mschema and JSON-Schema\n\nmschema has...\n\n- Brevity of syntax \n- Less features\n- JavaScript Support","publish_time":1387812634490,"_cnpm_publish_time":1387812634490,"dist-tags":{"latest":"0.5.6"}}