{"name":"@cfworker/json-schema","version":"1.8.3","keywords":["json-schema","jsonschema","json","schema","cloudflare","worker","workers","service-worker"],"author":{"name":"Jeremy Danyow","email":"jdanyow@gmail.com"},"license":"MIT","_id":"@cfworker/json-schema@1.8.3","maintainers":[{"name":"jdanyow","email":"jdanyow@gmail.com"}],"homepage":"https://github.com/cfworker/cfworker/tree/master/packages/json-schema/README.md","bugs":{"url":"https://github.com/cfworker/cfworker/issues"},"dist":{"shasum":"6db4d273da23d6e5725c3d7580fa801cd10a3cee","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.8.3.tgz","fileCount":31,"integrity":"sha512-rU8JLR0Xd+uMVo2NTBWlf0zd6xOYUeQf6zzZYtrVxp8u0W4IbYGgOuxCjqegNrl+I7pCP9P8gL8h/kwZsju7Tg==","signatures":[{"sig":"MEUCIGKU/h9jkZs9F3iBlK523/rRBA32TWofZsh6K5p6dK0LAiEAscP9g+XZirDG330QCMPxAtS48rhFP6Oh+HDbCqRQcfc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":109645,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg7iZXCRA9TVsSAnZWagAA7KgQAIQFMbsALjY943kxM+NZ\nckBAoa9GEU1I6jYcxuQzK23ppLlcIGNWCX735/PS7Y8M8aPBRfesAqH/Ky5j\nSSrkvcPuq1UCXwURvMTaJCbXTRT1PiFXNDAw8Wo5QF/eiqrMvG6iCMYaU0I9\nBZtYcSA+ADQMq/F6cy6jnf46Dg06JrJlkCJy4u+nqNas9kgAP4P8jQzGPAHw\n1kPjXg0DLDCGFjwSuBmdDlif9FjOfGv/m33Dxrh7F9hgZ/6oWFvcX5Ql4kn9\nUWnmSaZ0HB98gAX0rBSPAnZNMC6H03wjktvH5AGUtT40EN2H/jjPmxZ0LLkI\ngyNFzQBLNrdqyeh0oH3PQTn/BXKrz4olJDXwbaR1h5j1CjxxkVR5lAoUhZ5O\nXL5iqKWNNF0xKIZMBiYigCDbcJqkmORD8zKLXdkkOdHvnQ5H7Q7Ra74vSG0j\n/suHMxeTkSw5Elw49UUmO42CDaB4EvAPVcSa1GwWNimbhJDCYKnlE34ux0hV\n3FjSkbwIrmWSbHAvV5ZnMDC3v7Xt4qu9KUN5PM6VCwn7nVGQVQYGwa30m9Pb\nN3bsF/36VIS5dQrkgAAoY3pVl3bsnUyidZj2spS1gvjDBuTOqI+7p5I45i+L\nqJVeHD6G66xsTVvqdaIGwqCtsblBndcYvIwna1lonSdShPDD5fr90zv+HufS\nM2Qf\r\n=aamx\r\n-----END PGP SIGNATURE-----\r\n","size":21134,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.8.3.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","source":"src/index.ts","gitHead":"674fb1649bd1686f9918ac90436da709381cffb9","scripts":{"test":"cfworker test test/**/*.spec.ts --nocheck","build":"tsc --build","clean":"tsc --build --clean","pretest":"node --experimental-import-meta-resolve suite-gen.js"},"_npmUser":{"name":"jdanyow","email":"jdanyow@gmail.com"},"repository":{"url":"git+https://github.com/cfworker/cfworker.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v16.4.2+x64 (linux)","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09.","directories":{},"sideEffects":false,"_nodeVersion":"16.4.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","mocha":"^8.3.2","typescript":"^4.2.3","@types/chai":"^4.2.16","@types/mocha":"^8.2.2","@cfworker/dev":"^1.8.3","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#ac63eb7"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.8.3_1626220118868_0.9180467884275221","host":"s3://npm-registry-packages"},"readme":"# @cfworker/json-schema\n\n![](https://badgen.net/bundlephobia/minzip/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/min/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/dependency-count/@cfworker/json-schema)\n![](https://badgen.net/bundlephobia/tree-shaking/@cfworker/json-schema)\n![](https://badgen.net/npm/types/@cfworker/json-schema?icon=typescript)\n\nA JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.\n\nThis library is validated against the [json-schema-test-suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite), a series of approximately 4,500 assertions maintained along with the json-schema specification. A small set of test cases are intentionally not supported due to performance constraints or lack of feature use. These list of unsupported features are maintained in [test/unsupported.ts](./test/unsupported.ts). While this library is not the fastest due to lack of code generation, it's consistently among the [most spec compliant](https://json-schema.org/implementations.html#benchmarks).\n\n## Background\n\n_Why another JSON schema validator?_\n\nCloudflare workers do not have APIs required by [Ajv](https://ajv.js.org/) schema compilation (`eval` or `new Function(code)`).\nIf possible use Ajv in a build step to precompile your schema. Otherwise this library could work for you.\n\n## Basic usage\n\n```js\nimport { Validator } from '@cfworker/json-schema';\n\nconst validator = new Validator({ type: 'number' });\n\nconst result = validator.validate(7);\n```\n\n## Specify meta schema draft\n\n```js\nconst validator = new Validator({ type: 'number' }, '4'); // draft-4\n```\n\n## Add schemas\n\n```js\nconst validator = new Validator({\n  $id: 'https://foo.bar/baz',\n  $ref: '/beep'\n});\n\nvalidator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });\n```\n\n## Include all errors\n\nBy default the validator stops processing after the first error. Set the `shortCircuit` parameter to `false` to emit all errors.\n\n```js\nconst shortCircuit = false;\n\nconst draft = '2019-09';\n\nconst schema = {\n  type: 'object',\n  required: ['name', 'email', 'number', 'bool'],\n  properties: {\n    name: { type: 'string' },\n    email: { type: 'string', format: 'email' },\n    number: { type: 'number' },\n    bool: { type: 'boolean' }\n  }\n};\n\nconst validator = new Validator(schema, draft, shortCircuit);\n\nconst result = validator.validate({\n  name: 'hello',\n  email: 5, // invalid type\n  number: 'Hello' // invalid type\n  bool: 'false' // invalid type\n});\n```\n","publish_time":1626220119004,"_cnpm_publish_time":1626220119004,"dist-tags":{"latest":"4.1.6"}}