{"name":"@cfworker/json-schema","version":"1.6.10","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.10","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":"bef7707fb1b1792dded29090146c8e5d2cf430a6","tarball":"http://registry-npm.ywwl.com/@cfworker/json-schema/download/@cfworker/json-schema-1.6.10.tgz","fileCount":31,"integrity":"sha512-0hYMms3biixuJSdF/SHPqD17GcNMujeuu2oMyGa8rc9IOLPXU+heCr9qay6Y6ATQQnKNEX8BgRFS+t56lgd2jA==","signatures":[{"sig":"MEQCIGwHJ4n7rIKT4n1GrF860x+Xonnj1pbmyAN9rjBrCseIAiAwIJmWKHusFq6qX6HGmApLH3/dZw2vPcWg6rMBXKYRNA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":109343,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYOe/CRA9TVsSAnZWagAAaVcP/12gv8O9pXfHmdANKEUu\nqJxSsHcu4WQGpbMrRvMefA0l0uquGZxwK9+gXojStcx/+YgQJYxFuLD/0cqf\n+wzacKyhkQhRBc5lg7sqNWU48rwUEko3UMqoXrIs75ftfjfnjBc8B9HR0pZ4\n1JqYlB30Pryifyrx2hmsfEO8QhGxXzqH1pQtaRz/oYmwEGTzEyH49Ld5W/xj\ngHGr3T5wWN2JrubPm0O2SBTN7KHgVkaIzxSC/HQE8W+WHOYIFY2tAbi3OMJe\ny+Wqz3Rl6Im4kiIjpiMr5Rw/JSlyvwoVwbWEtw3zYXCuPQluLL4zzvEaRIDW\nxflXY7HK/g101ml9OXuUO7sI0JaDr9MX9HPtKg9DNCpJ4BYG7v6UgKhvn0To\niZfjTiySyMtrGk0n21AGQh8/HdTirwJb6X9CPb3ef0Hyd3FAJgDdq3hpwlNk\n3cQZKnvAE/vZZw8IaVI0SZxwjBBPweEHuyLnASZnlNllJj0TmmM+/8kCv+B0\nXxVQ17k0tlERqcZbztu9k/vlHkMF66PBF6oGKm9wtopbzUOCHNexJofIKmFF\n/G1wV8sCR/FT22fV3YEFfKuwO/LT4sxraqhw8GT+PIS1z3Ubf+pB9yZ+1+pQ\nVRg92ZjQqyly4Q3ey+m7hIzNRS7KillX7/BavAJf/nWNIFIM8cId21Q0+xl9\nlwNh\r\n=rcwR\r\n-----END PGP SIGNATURE-----\r\n","size":21063,"noattachment":false,"key":"/@cfworker/json-schema/-/@cfworker/json-schema-1.6.10.tgz"},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","source":"src/index.ts","gitHead":"4113f84da719850346f215e2c681940eccc48c69","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.16.0+x64 (linux)","description":"A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, and 2019-09.","directories":{},"_nodeVersion":"14.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.0","mocha":"^8.3.0","typescript":"^4.1.5","@types/chai":"^4.2.15","@types/mocha":"^8.2.1","@cfworker/dev":"^1.6.10","json-schema-test-suite":"git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git#ac63eb7"},"_npmOperationalInternal":{"tmp":"tmp/json-schema_1.6.10_1616963518640_0.0675332120110812","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":1616963518837,"_cnpm_publish_time":1616963518837,"dist-tags":{"latest":"4.1.6"}}