Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@cfworker/json-schema
Advanced tools
A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.
A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.
This library is validated against the 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. While this library is not the fastest due to lack of code generation, it's consistently among the most spec compliant.
Why another JSON schema validator?
Cloudflare workers do not have APIs required by Ajv schema compilation (eval
or new Function(code)
).
If possible use Ajv in a build step to precompile your schema. Otherwise this library could work for you.
import { Validator } from '@cfworker/json-schema';
const validator = new Validator({ type: 'number' });
const result = validator.validate(7);
const validator = new Validator({ type: 'number' }, '4'); // draft-4
const validator = new Validator({
$id: 'https://foo.bar/baz',
$ref: '/beep'
});
validator.addSchema({ $id: 'https://foo.bar/beep', type: 'boolean' });
By default the validator stops processing after the first error. Set the shortCircuit
parameter to false
to emit all errors.
const shortCircuit = false;
const draft = '2019-09';
const schema = {
type: 'object',
required: ['name', 'email', 'number', 'bool'],
properties: {
name: { type: 'string' },
email: { type: 'string', format: 'email' },
number: { type: 'number' },
bool: { type: 'boolean' }
}
};
const validator = new Validator(schema, draft, shortCircuit);
const result = validator.validate({
name: 'hello',
email: 5, // invalid type
number: 'Hello' // invalid type
bool: 'false' // invalid type
});
FAQs
A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.
The npm package @cfworker/json-schema receives a total of 73,606 weekly downloads. As such, @cfworker/json-schema popularity was classified as popular.
We found that @cfworker/json-schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.