{"name":"@cfworker/json-schema","version":"1.12.4","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.12.4","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":"93f767038eb04e16fb26ddf66caa36931da02053","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.12.4.tgz","fileCount":30,"integrity":"sha512-Uixq/lBfvw9Gwj68OP/breqzpWOPgxE+38z/LJB01exvaGhi9hlPoSSNWddClYFg7jTVwrDzCXCefyDFOexMZw==","signatures":[{"sig":"MEQCIG0qa2/dMbyWlEHQt2qr1zKk+RBrceb02WAEDk7dQHurAiApYcEF67XgYLr+0xsUlGYnrjv50YvLyKZksfVti6p3bw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":112879,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi+YXbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrskhAAi6Kadz51hMBkZeuX4jQThTMG7/3IPqpnckD6H6vYxGA/grC9\r\nBA3QiZjKLggi5Nr+tbAFUG/Mljgns2DX5SUIiDVG0T7pGZtCjJJJp0D9T7oC\r\n7jyiBZ+ILaDCtklWiNZY42a2xGTzxEXfnKS33OC3nRLPB/WzXXIXc+b0LnvQ\r\nxkukVy9DCSnQbGMeUeoeWqB/TgXIgqdnvn4j5/F4OoRao7moM0T2BmpCjtbg\r\ng8wHiirL6AE8VqCxQo8VDYB/kgesjDe6aSUDWqwjHkgDvGB88/dm8vAeIN0y\r\ntKKc+R8zC67SqWC7GSpQiVgV+N320yBc52QlirwNJYRq9gyoYNfwhj4qxepb\r\nalThXVg3d8qfjjUfRwDgTGAOerS45WwvfB4ki/zcUXbU7JvfTr9ye2STs4cn\r\noYglKgZEdNNh1KJgfMnOwXRv3rvHxMNGKgSLhH7GDiLSisP+zCQTYEAhR7IK\r\nMLxS0OJGRy06Ty+IlpoWm+hyt1sdZjY7SZ4PSpGYJimV5QPfEUEuvF8ao/Y1\r\naUq4B4Dz/uep94FQAqKXNgEwf68coDUqMcsFgN5RUtjrzuYKPjBxRbnH2wpD\r\nP+fdcMzhGaX0AF6zDeOwtRwn1dcY578jYRhQUjRBrZ/ExC+sD+6yhjrLNWJk\r\nfKKpQUMcyOCnjx9iivpq2HzLMSl0xp3PFPg=\r\n=2lO+\r\n-----END PGP SIGNATURE-----\r\n","size":20674,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.12.4.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"8fae9c7fe7f8174b56671c4f44c44bce4b28166d","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":"8.5.0","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.","directories":{},"sideEffects":false,"_nodeVersion":"16.14.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.6","mocha":"^10.0.0","typescript":"^4.7.4","@types/chai":"^4.3.3","@types/mocha":"^9.1.1","@cfworker/dev":"^1.14.1","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#76b529f"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.12.4_1660519899521_0.7873765321456638","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":1660519899705,"_cnpm_publish_time":1660519899705,"dist-tags":{"latest":"4.1.6"}}