{"_id":"jscheme","_rev":"11-b8e44c0106d07bbb84bd43ed26250fb5","name":"jscheme","description":"A small and simple object schema library for the browser and node","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"jscheme","version":"0.1.0","author":{"name":"upfront.io"},"description":"A small and simple object schema library for the browser and node","keywords":["schema","json schema","object schema","validation"],"license":"MIT","repository":{"type":"git","url":"git://github.com/upfrontIO/jscheme.git"},"main":"lib/jscheme.js","homepage":"https://github.com/upfrontIO/jscheme","devDependencies":{"browserify":"^6.2.0","chai":"^1.9.2","coffeeify":"^0.7.0","grunt":"^0.4.5","grunt-browserify":"^3.1.0","grunt-bump":"0.0.16","grunt-contrib-clean":"^0.6.0","grunt-contrib-coffee":"^0.12.0","grunt-contrib-concat":"^0.5.0","grunt-contrib-copy":"^0.7.0","grunt-contrib-uglify":"^0.6.0","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.9.0","grunt-mocha-test":"^0.12.2","karma":"^0.12.24","karma-chrome-launcher":"^0.1.5","karma-coffee-preprocessor":"^0.2.1","karma-firefox-launcher":"^0.1.3","karma-mocha":"^0.1.9","karma-phantomjs-launcher":"^0.1.4","karma-safari-launcher":"^0.1.1","karma-script-launcher":"^0.1.0","karma-sinon-chai":"^0.2.0","load-grunt-tasks":"^1.0.0","mocha":"^2.0.1","sinon":"^1.11.1"},"engines":{"node":">=0.10.0"},"gitHead":"4429c31a7c542d0a5367ee2d01ae25b2a7e5ec2d","bugs":{"url":"https://github.com/upfrontIO/jscheme/issues"},"_id":"jscheme@0.1.0","scripts":{},"_shasum":"58d1260130b5c02f1228821a77522d5aa1c6ed16","_from":".","_npmVersion":"2.1.2","_nodeVersion":"0.10.25","_npmUser":{"name":"peyerluk","email":"lukas@upfront.io"},"maintainers":[{"name":"peyerluk","email":"lukas@upfront.io"}],"dist":{"shasum":"58d1260130b5c02f1228821a77522d5aa1c6ed16","tarball":"https://registry.npmjs.org/jscheme/-/jscheme-0.1.0.tgz","integrity":"sha512-HQxseHpOu+jQyZO+hI+Rtc5FkIxktTqACty++xl4kUGkXUuHr+eyj58LKQ+AvNtVBWdmtZhAe39ImYEPjBNk/Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoSYY+ihT1c0BIt8g4+JhRXGNEhldz6KfXzgsR0UwatQIgSBckN9HpsrSSlTm8LRRABSp6zrvemxY5khZAo14lXd4="}]}},"0.2.0":{"name":"jscheme","version":"0.2.0","author":{"name":"upfront.io"},"description":"A small and simple object schema library for the browser and node","keywords":["schema","json schema","object schema","validation"],"license":"MIT","repository":{"type":"git","url":"git://github.com/upfrontIO/jscheme.git"},"main":"lib/jscheme.js","homepage":"https://github.com/upfrontIO/jscheme","devDependencies":{"browserify":"^6.2.0","chai":"^1.9.2","coffeeify":"^0.7.0","grunt":"^0.4.5","grunt-browserify":"^3.1.0","grunt-bump":"0.0.16","grunt-contrib-clean":"^0.6.0","grunt-contrib-coffee":"^0.12.0","grunt-contrib-concat":"^0.5.0","grunt-contrib-copy":"^0.7.0","grunt-contrib-uglify":"^0.6.0","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.9.0","grunt-mocha-test":"^0.12.2","karma":"^0.12.24","karma-chrome-launcher":"^0.1.5","karma-coffee-preprocessor":"^0.2.1","karma-firefox-launcher":"^0.1.3","karma-mocha":"^0.1.9","karma-phantomjs-launcher":"^0.1.4","karma-safari-launcher":"^0.1.1","karma-script-launcher":"^0.1.0","karma-sinon-chai":"^0.2.0","load-grunt-tasks":"^1.0.0","mocha":"^2.0.1","sinon":"^1.11.1"},"engines":{"node":">=0.10.0"},"gitHead":"685d925a1764f610b62308901fbd8186f43d3b79","bugs":{"url":"https://github.com/upfrontIO/jscheme/issues"},"_id":"jscheme@0.2.0","scripts":{},"_shasum":"56b8d8fdd100fe78411936c919c177581f83d9d4","_from":".","_npmVersion":"2.1.2","_nodeVersion":"0.10.25","_npmUser":{"name":"peyerluk","email":"lukas@upfront.io"},"maintainers":[{"name":"peyerluk","email":"lukas@upfront.io"}],"dist":{"shasum":"56b8d8fdd100fe78411936c919c177581f83d9d4","tarball":"https://registry.npmjs.org/jscheme/-/jscheme-0.2.0.tgz","integrity":"sha512-Ryq2q6dp07SzP/b3fsexvUtxbbSYyrybukVmqikWcbNUatOLvXdq3X86iOK3rvtEVIfnyCX4TLI+/iSCGA1aLw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGlFhQ/O2J5Mqg+Q3bf7CkwhBCLDndlrW65XsXKhjgAxAiEAtcKz5fFd6LsyNU6THBt7q2KpRsoWzWuqq4KhVCC6tYE="}]}},"0.2.1":{"name":"jscheme","version":"0.2.1","author":{"name":"upfront.io"},"description":"A small and simple object schema library for the browser and node","keywords":["schema","json schema","object schema","validation"],"license":"MIT","repository":{"type":"git","url":"git://github.com/upfrontIO/jscheme.git"},"main":"lib/jscheme.js","homepage":"https://github.com/upfrontIO/jscheme","devDependencies":{"browserify":"^6.2.0","chai":"^1.9.2","coffeeify":"^0.7.0","grunt":"^0.4.5","grunt-browserify":"^3.1.0","grunt-bump":"0.0.16","grunt-contrib-clean":"^0.6.0","grunt-contrib-coffee":"^0.12.0","grunt-contrib-concat":"^0.5.0","grunt-contrib-copy":"^0.7.0","grunt-contrib-uglify":"^0.6.0","grunt-contrib-watch":"^0.6.1","grunt-karma":"^0.9.0","grunt-mocha-test":"^0.12.2","grunt-shell":"^1.1.1","karma":"^0.12.24","karma-chrome-launcher":"^0.1.5","karma-coffee-preprocessor":"^0.2.1","karma-firefox-launcher":"^0.1.3","karma-mocha":"^0.1.9","karma-phantomjs-launcher":"^0.1.4","karma-safari-launcher":"^0.1.1","karma-script-launcher":"^0.1.0","karma-sinon-chai":"^0.2.0","load-grunt-tasks":"^1.0.0","mocha":"^2.0.1","sinon":"^1.11.1"},"engines":{"node":">=0.10.0"},"gitHead":"56985c669eaf89b001c52b96286f993db94b4ce4","bugs":{"url":"https://github.com/upfrontIO/jscheme/issues"},"_id":"jscheme@0.2.1","scripts":{},"_shasum":"c1712846d15d6e45fdd1ef377efbd62832594bfd","_from":".","_npmVersion":"2.1.2","_nodeVersion":"0.10.25","_npmUser":{"name":"peyerluk","email":"lukas@upfront.io"},"maintainers":[{"name":"peyerluk","email":"lukas@upfront.io"}],"dist":{"shasum":"c1712846d15d6e45fdd1ef377efbd62832594bfd","tarball":"https://registry.npmjs.org/jscheme/-/jscheme-0.2.1.tgz","integrity":"sha512-J7JvzELXUrkzcpeax8FbbbBDKAhNGm5DzAmiRWKhiGUz3owTwZD9s5xIE4l1XnUm+23JXBCYCPNcDM3pfOnUVw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIQDv1KPUHM9ekpFSShF8dKLWfp4FjEECSYSUwIBSISbXVgIfREejNOM0s7m9Igz+cK1apZY2F3exNcf99tLIRPuQ8A=="}]}}},"readme":"# jScheme\n\nA small and simple object schema library for the browser and node. \nIt has no dependencies and comes in under 3KB compressed and gzipped.\n\n### Basic Usage\n\nHere is a most simple example to validate an object with one property which has to be a string:\n\n```javascript\n// Add a schema.\njScheme.add('person', {\n    name: 'string'\n}); \n\n// Validate a valid object against our first schema.\njScheme.validate('person', {\n    name: 'Popeye'\n});\n\n// Let's see what happens if we check with an empty object.\njScheme.validate('person', {}); // false\njScheme.hasErrors(); // true\njScheme.getErrorMessages(); // ['person.name: required property missing']\n```\n\n### Validators\n\nYou can add one or more validators to a property in a comma-separated validation string:\n\nLike this: `property: 'boolean, optional'`\n\n\n#### Predefined Validators\n\nFor your convenience there are a few predefined validators:\n\n - `string`\n - `boolean`\n - `number`\n - `function`\n - `array`\n - `date`\n - `regexp`\n - `object`\n - `falsy`\n - `truthy`\n - `not empty`  \n   In fact the same as 'truthy' but it reads nicer, doesn't it?\n\n\n#### Special Validators\n\n - `array of {{ validator }}`  \n   E.g. 'array of string'\n - `optional`  \n   By default all propoerties you specify are required. With this you can mark one as optional.\n - `required`  \n   If you set the configuration `propertiesRequired` to `false` you can use this validator to mark a property as required.\n\n\n#### Special Properties\n\n - `__validate`  \n   Adds a validation to the parent property.\n - `__additionalProperty`  \n   Here you can define a method that will be called for every unspecified additional property. The methods signature looks like this: `function(key, value) { return false }`.\n\n\n### A more complex example\n\n```javascript\n// Let's try a more feisty schema\njScheme.add('person', {\n    name: 'string'\n    specialPowers:\n        __additionalProperty: function(key, value) { return jScheme.validate('power', value) }\n    relationshipStatus: 'relationship status'\n    archenemies: 'array of villain, optional'\n}); \n\n// Add another schema that can be nested in the first one\njScheme.add('villain', {\n    name: 'string'\n    dislikes: 'array of string'\n});\n\njScheme.add('power', {\n    hurts: 'boolean'\n    hurtsMuch: 'boolean, optional'\n});\n\n// Add a custom validator for the relationship status\njScheme.add('relationship status', function(value) {\n    return /it\\'s (complicated|relaxed|depressing)/.test(value)\n});\n\njScheme.validate('person', {\n   name: 'Peter Pan'\n   specialPowers:\n     'nagging':  { hurts: true }\n    relationshipStatus: \"it's complicated\"\n    archenemies: [\n        { name: 'John', dislikes: ['baby seals'] },\n        { name: 'Mary', dislikes: ['fun', 'flirting'] }\n    ]\n});\n```\n\n\n### Add your own Validators\n\nYou can add your own validators. They are treated just the same as the predefined ones. Also there is no difference if you add a schema or a validator in the way you define them in a validation string. The name of your validator can contain whitespaces so it is easier to read.\n\n```javascript\njScheme.add('your validator', function(value) {\n    return true || false\n});\n```\n\n### Configuration\n\n```javascript\njScheme.configure({ \n  allowAdditionalProperties: true\n  propertiesRequired: true\n});\n```\n\n**allowAdditionalProperties (default: true)**  \nObjects are allowed to have other properties than the ones specified.\n\n**propertiesRequired (default: true)**  \nThe properties added in the schemas are required by default. If you want to make a property optional you can use the validator `optional`. If this configuration is set to false all properties will be optional by default and you can mark them as required with the validatior `required`.\n\n\n## License\n\njScheme is licensed under the [MIT License](LICENSE).\n\nIn Short:\n\n- You can use, copy and modify the software however you want.\n- You can give the software away for free or sell it.\n- The only restriction is that it be accompanied by the license agreement.\n","maintainers":[{"name":"livingdocs-bot","email":"dev@livingdocs.io"},{"name":"peyerluk","email":"lukas@upfront.io"}],"time":{"modified":"2022-06-19T05:52:29.621Z","created":"2014-10-31T13:02:43.228Z","0.1.0":"2014-10-31T13:02:43.228Z","0.2.0":"2014-11-03T17:22:21.601Z","0.2.1":"2015-01-26T17:24:35.806Z"},"homepage":"https://github.com/upfrontIO/jscheme","keywords":["schema","json schema","object schema","validation"],"repository":{"type":"git","url":"git://github.com/upfrontIO/jscheme.git"},"author":{"name":"upfront.io"},"bugs":{"url":"https://github.com/upfrontIO/jscheme/issues"},"license":"MIT","readmeFilename":"README.md","users":{"peyerluk":true,"marcbachmann":true}}