{"name":"@cfworker/json-schema","version":"1.6.5","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.6.5","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":"eb83790f6636011d8598d70701ab720d4a8b30cb","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.6.5.tgz","fileCount":31,"integrity":"sha512-KiiM/lwz9fuUZCWMYwMsblnR5jbteVpMZQ2bm0mw+zRIqlDvVkWjJ5pCg80zbrWh7D6u95sz7nZI7IXRCJTzsA==","signatures":[{"sig":"MEUCIFKMmOoHvuXSxqkvSXdQSGI2IFhbXMHAHVQejxJECwYEAiEAyzXDdUAE9dqS+J+/rz5R7cXfTXNU/E3jIOxw+0Y4HoU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":108312,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf2ZqvCRA9TVsSAnZWagAAE+8P+gPP1bkG9eJenVi9SZPy\nTzXUVkUUOZzyK8iaNQr4kC1NWMOf32b4LQA/MGKfVcdDzPliew7fUr8Q3c/7\noW4iPaqIfVK2o0RnUTjLZs3sRtBTp7dWE01MqUYEBmCBEJbkwzzipT/Za/u7\nXjWCJkr61f5aMvKJnDi1fv3UFiv0Ley15D/U0TPgn9vUdkSSmgbxw5uHgWEV\neKDUQKtc919SC/bOPBlD86ZAghiL+1qmGrdEAMk8y9v6NYBeu3QCURMQjg4d\n2olj6B2ymP5TDJqfaGCT153eR118UHtOo8F451dntM2oju0KkdWp/Rz8tlNR\nBSblVvYCF6l4DVWleaXb9v66NZMC9BZ5zhheoOgsQz06C2bdAN5pZSFAzhJe\nrafZ9FOpRkrEcuBCZwQiyOpmfKb/QRxMtTxlkjkeDWkMIaLL7Vm69XfP01gu\ny6JWOO9Ln50OTAa2bbohVGuaz80GwwqPVb+rnupVQCXNrA1kvPwNFIK13t3I\nUdCOeWMEHE72ARTjkbodYQ2kpEAd3MUYa71PCqSz0MmYYSA/omi/NtdXOOyp\n40F1aOjBkfZnpgQlmqXrki6FbXSu7uVh4js0lj0tt7g7KnvG7HMv0qyjf9Lt\n94eFPvNZlkB0nqo3bn17wA1ljvK9O3GmalwcQ1+7BluAqgrVEZqGcmhufi6i\nnSZ7\r\n=rCuL\r\n-----END PGP SIGNATURE-----\r\n","size":20952,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.6.5.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","source":"src/index.ts","gitHead":"b544e6aeb2e60ae8e73384fb29ffcdfa58fbff7b","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@v14.4.0+x64 (linux)","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09.","directories":{},"_nodeVersion":"14.4.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","mocha":"^8.1.3","typescript":"^4.0.3","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@cfworker/dev":"^1.6.5","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#ac63eb7"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.6.5_1608096430827_0.6334903468492683","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":1608096430972,"_cnpm_publish_time":1608096430972,"dist-tags":{"latest":"4.1.6"}}