{"name":"@cfworker/json-schema","version":"1.2.17","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.2.17","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":"508dab2bfdfbbc5c738cf8962a2fd905d3e08e01","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.2.17.tgz","fileCount":31,"integrity":"sha512-iSVYSiS99Ft8FsnzqKF7leFLr4tk8Ei/XWkL5c3okSN/2YO7qvjl57DKMUOnGIt0rQf9e8gLWKP5iNzaQBcSfA==","signatures":[{"sig":"MEYCIQDiDHjZfE9MEsQ6sjW27ZvAmlVmBv/XDD/W79vIWvsyIwIhAN4g3QA/sDqHuefFQw7RlRsmkUH+ZFo+CGfRjJ92hhkA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":105659,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA32CCRA9TVsSAnZWagAAtnwP/3Q7lQtOLx73sdbR+UBZ\nRrzYQaP9gMdliJkGIfzR4+Myv8ZOJlskUxBW+5u8/lIFEkJD/jQ+t5gR0qOd\ncD4vxHCcbyEsosT4uBdPqM2Vh8iqOj8EyzNMlALb9/9f1FkMHgDVFlxTXcNv\nbJvk4GospZvduWHiHIhuj2TTSN7pXnkMcdFpMBL2NlmyyWJFaMxzvu/N5mkc\nHEAe0zcDTw7ZKyEylJOoZVZFnpotmPNpxP9kNmXEPWbE9YJ32cwRj1OyHLsv\nyTqA/q/Tj0o1KjU7+SRA6SA2qES+k55Pdr+yJXheA3kgSpRmn3p2wRdBH7a1\nk3S8dpqesxBywQvz6Chcxc3K1Ea5l2IHQv0T45e1/+u+ja0mF++g2/8/txL6\nThsm2uAOoXPSwp4W8zhfDG3fEbRR0luNuxhYTuvTKJYMID24RGposqK/7Uow\nZzemnGfnquKxpmXj+kC8TtHwiXheD8NZyZYKXuuTzhLNctspU1gvkvFmZh+6\nsxIYVRWoW0vNqCav+wmC4IOzNjRVnq0YAeYu3vp42XU76gqxi/BwnoY7eD8z\nc88RndCP1ofPDf8du3nipC3f0GX2B3eO9gHz8e5EcMZFa8qRJnGi0815orX8\ny8k/3tktLSK7TxoXm/diZ2jZQXwSN5HEZ7FNgcPkVt2EmSm7aM7EwtyUjNVG\nRFYH\r\n=HAy/\r\n-----END PGP SIGNATURE-----\r\n","size":20303,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.2.17.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","source":"src/index.ts","gitHead":"f0ca075e2ceda4b60f6d9e6531d677a7f0a46843","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.0.1","typescript":"^3.9.5","@types/chai":"^4.2.11","@types/mocha":"^7.0.2","@cfworker/dev":"^1.2.17","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#ac63eb7"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.2.17_1594064257973_0.21876910516862424","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":1594064258090,"_cnpm_publish_time":1594064258090,"dist-tags":{"latest":"4.1.6"}}