110 lines
12 KiB
JSON
110 lines
12 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "jsonschema@^1.1.0",
|
|
"scope": null,
|
|
"escapedName": "jsonschema",
|
|
"name": "jsonschema",
|
|
"rawSpec": "^1.1.0",
|
|
"spec": ">=1.1.0 <2.0.0",
|
|
"type": "range"
|
|
},
|
|
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl"
|
|
]
|
|
],
|
|
"_from": "jsonschema@>=1.1.0 <2.0.0",
|
|
"_id": "jsonschema@1.2.2",
|
|
"_inCache": true,
|
|
"_location": "/jsonschema",
|
|
"_nodeVersion": "8.9.1",
|
|
"_npmOperationalInternal": {
|
|
"host": "s3://npm-registry-packages",
|
|
"tmp": "tmp/jsonschema-1.2.2.tgz_1512980134346_0.7657116004265845"
|
|
},
|
|
"_npmUser": {
|
|
"name": "tdegrunt",
|
|
"email": "tom@degrunt.nl"
|
|
},
|
|
"_npmVersion": "5.5.1",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "jsonschema@^1.1.0",
|
|
"scope": null,
|
|
"escapedName": "jsonschema",
|
|
"name": "jsonschema",
|
|
"rawSpec": "^1.1.0",
|
|
"spec": ">=1.1.0 <2.0.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/xdl"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz",
|
|
"_shasum": "83ab9c63d65bf4d596f91d81195e78772f6452bc",
|
|
"_shrinkwrap": null,
|
|
"_spec": "jsonschema@^1.1.0",
|
|
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl",
|
|
"author": {
|
|
"name": "Tom de Grunt",
|
|
"email": "tom@degrunt.nl"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/tdegrunt/jsonschema/issues"
|
|
},
|
|
"contributors": [
|
|
{
|
|
"name": "Austin Wright"
|
|
}
|
|
],
|
|
"dependencies": {},
|
|
"description": "A fast and easy to use JSON Schema validator",
|
|
"devDependencies": {
|
|
"chai": "~1.5.0",
|
|
"mocha": "~1.8.2"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"integrity": "sha512-iX5OFQ6yx9NgbHCwse51ohhKgLuLL7Z5cNOeZOPIlDUtAMrxlruHLzVZxbltdHE5mEDXN+75oFOwq6Gn0MZwsA==",
|
|
"shasum": "83ab9c63d65bf4d596f91d81195e78772f6452bc",
|
|
"tarball": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz"
|
|
},
|
|
"engines": {
|
|
"node": "*"
|
|
},
|
|
"gitHead": "7627244953de64299862647c166b2cac02fe2a7a",
|
|
"homepage": "https://github.com/tdegrunt/jsonschema#readme",
|
|
"keywords": [
|
|
"json",
|
|
"schema",
|
|
"jsonschema",
|
|
"validator",
|
|
"validation"
|
|
],
|
|
"license": "MIT",
|
|
"main": "./lib",
|
|
"maintainers": [
|
|
{
|
|
"name": "tdegrunt",
|
|
"email": "tom@degrunt.nl"
|
|
},
|
|
{
|
|
"name": "acubed",
|
|
"email": "aaa@bzfx.net"
|
|
}
|
|
],
|
|
"name": "jsonschema",
|
|
"optionalDependencies": {},
|
|
"readme": "[![Build Status](https://secure.travis-ci.org/tdegrunt/jsonschema.svg)](http://travis-ci.org/tdegrunt/jsonschema)\n\n# jsonschema\n[JSON schema](http://json-schema.org/) validator, which is designed to be fast and simple to use.\nThe latest IETF published draft is v6, this library is mostly v4 compatible.\n\n## Contributing & bugs\nPlease fork the repository, make the changes in your fork and include tests. Once you're done making changes, send in a pull request.\n\n### Bug reports\nPlease include a test which shows why the code fails.\n\n## Usage\n\n### Simple\nSimple object validation using JSON schemas.\n\n```javascript\n var Validator = require('jsonschema').Validator;\n var v = new Validator();\n var instance = 4;\n var schema = {\"type\": \"number\"};\n console.log(v.validate(instance, schema));\n```\n\n### Even simpler\n\n```javascript\n var validate = require('jsonschema').validate;\n console.log(validate(4, {\"type\": \"number\"}));\n```\n\n### Complex example, with split schemas and references\n\n```javascript\n var Validator = require('jsonschema').Validator;\n var v = new Validator();\n\n // Address, to be embedded on Person\n var addressSchema = {\n \"id\": \"/SimpleAddress\",\n \"type\": \"object\",\n \"properties\": {\n \"lines\": {\n \"type\": \"array\",\n \"items\": {\"type\": \"string\"}\n },\n \"zip\": {\"type\": \"string\"},\n \"city\": {\"type\": \"string\"},\n \"country\": {\"type\": \"string\"}\n },\n \"required\": [\"country\"]\n };\n\n // Person\n var schema = {\n \"id\": \"/SimplePerson\",\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\"type\": \"string\"},\n \"address\": {\"$ref\": \"/SimpleAddress\"},\n \"votes\": {\"type\": \"integer\", \"minimum\": 1}\n }\n };\n\n var p = {\n \"name\": \"Barack Obama\",\n \"address\": {\n \"lines\": [ \"1600 Pennsylvania Avenue Northwest\" ],\n \"zip\": \"DC 20500\",\n \"city\": \"Washington\",\n \"country\": \"USA\"\n },\n \"votes\": \"lots\"\n };\n\n v.addSchema(addressSchema, '/SimpleAddress');\n console.log(v.validate(p, schema));\n```\n\nFor a comprehensive, annotated example illustrating all possible validation options, see [examples/all.js](./examples/all.js)\n\n## Features\n\n### Definitions\nAll schema definitions are supported, $schema is ignored.\n\n### Types\nAll types are supported\n\n### Formats\n#### Disabling the format keyword.\n\nYou may disable format validation by providing `disableFormat: true` to the validator\noptions.\n\n#### String Formats\nAll formats are supported, phone numbers are expected to follow the [E.123](http://en.wikipedia.org/wiki/E.123) standard.\n\n#### Custom Formats\nYou may add your own custom format functions. Format functions accept the input\nbeing validated and return a boolean value. If the returned value is `true`, then\nvalidation succeeds. If the returned value is `false`, then validation fails.\n\n* Formats added to `Validator.prototype.customFormats` do not affect previously instantiated\nValidators. This is to prevent validator instances from being altered once created.\nIt is conceivable that multiple validators may be created to handle multiple schemas\nwith different formats in a program.\n* Formats added to `validator.customFormats` affect only that Validator instance.\n\nHere is an example that uses custom formats:\n\n```\nValidator.prototype.customFormats.myFormat = function(input) {\n return input === 'myFormat';\n};\n\nvar validator = new Validator();\nvalidator.validate('myFormat', {type: 'string', format: 'myFormat'}).valid; // true\nvalidator.validate('foo', {type: 'string', format: 'myFormat'}).valid; // false\n```\n\n### Results\nThe first error found will be thrown as an `Error` object if `options.throwError` is `true`. Otherwise all results will be appended to the `result.errors` array which also contains the success flag `result.valid`.\n\nWhen `oneOf` or `anyOf` validations fail, errors that caused any of the sub-schemas referenced therein to fail are not reported, unless `options.nestedErrors` is truthy. This option may be useful when troubleshooting validation errors in complex schemas. \n\n### Custom properties\nSpecify your own JSON Schema properties with the validator.attributes property:\n\n```javascript\nvalidator.attributes.contains = function validateContains(instance, schema, options, ctx) {\n if(typeof instance!='string') return;\n if(typeof schema.contains!='string') throw new jsonschema.SchemaError('\"contains\" expects a string', schema);\n if(instance.indexOf(schema.contains)<0){\n return 'does not contain the string ' + JSON.stringify(schema.contains);\n }\n}\nvar result = validator.validate(\"i am an instance\", { type:\"string\", contains: \"i am\" });\n// result.valid === true;\n```\n\nThe instance passes validation if the function returns nothing. A single validation error is produced\nif the fuction returns a string. Any number of errors (maybe none at all) may be returned by passing a\n`ValidatorResult` object, which may be used like so:\n\n```javascript\n var result = new ValidatorResult(instance, schema, options, ctx);\n while(someErrorCondition()){\n result.addError('fails some validation test');\n }\n return result;\n```\n\n### Dereferencing schemas\nSometimes you may want to download schemas from remote sources, like a database, or over HTTP. When importing a schema,\nunknown references are inserted into the `validator.unresolvedRefs` Array. Asynchronously shift elements off this array and import\nthem:\n\n```javascript\n var Validator = require('jsonschema').Validator;\n var v = new Validator();\n v.addSchema(initialSchema);\n function importNextSchema(){\n var nextSchema = v.unresolvedRefs.shift();\n if(!nextSchema){ done(); return; }\n databaseGet(nextSchema, function(schema){\n v.addSchema(schema);\n importNextSchema();\n });\n }\n importNextSchema();\n```\n\n### Pre-Property Validation Hook\nIf some processing of properties is required prior to validation a function may be passed via the options parameter of the validate function. For example, say you needed to perform type coercion for some properties:\n\n```const coercionHook = function (instance, property, schema, options, ctx) {\n var value = instance[property];\n\n // Skip nulls and undefineds\n if (value === null || typeof value == 'undefined') {\n return;\n }\n\n // If the schema declares a type and the property fails type validation.\n if (schema.type && this.attributes.type.call(this, instance, schema, options, ctx.makeChild(schema, property))) {\n var types = (schema.type instanceof Array) ? schema.type : [schema.type];\n var coerced = undefined;\n\n // Go through the declared types until we find something that we can\n // coerce the value into.\n for (var i = 0; typeof coerced == 'undefined' && i < types.length; i++) {\n // If we support coercion to this type\n if (lib.coercions[types[i]]) {\n // ...attempt it.\n coerced = lib.coercions[types[i]](value);\n }\n }\n // If we got a successful coercion we modify the property of the instance.\n if (typeof coerced != 'undefined') {\n instance[property] = coerced;\n }\n }\n}.bind(validator)\n\n// And now, to actually perform validation with the coercion hook!\nv.validate(instance, schema, { preValidateProperty: coercionHook });\n```\n\n## Tests\nUses [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) as well as our own tests.\nYou'll need to update and init the git submodules:\n\n git submodule update --init\n npm test\n\n## Contributions\n\nThis library would not be possible without the valuable contributions by:\n\n- Austin Wright\n\n... and many others!\n\n## License\n\n jsonschema is licensed under MIT license.\n\n Copyright (C) 2012-2015 Tom de Grunt <tom@degrunt.nl>\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n of the Software, and to permit persons to whom the Software is furnished to do\n so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git://github.com/tdegrunt/jsonschema.git"
|
|
},
|
|
"scripts": {
|
|
"test": "mocha -R spec"
|
|
},
|
|
"typings": "./lib/index.d.ts",
|
|
"version": "1.2.2"
|
|
}
|