
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
@iotcomms.io/chai-json-pattern
Advanced tools
Deep matching objects with clear, JSON-like syntax.
Chai JSON pattern allows you to create blueprints for JavaScript objects to ensure validation of key information. It enables you to use JSON syntax extend with easy to use validators. It came up mostly for testing API with cucumber-js, but can be used in any application. Additionaly you can extend base functionality with custom validators. For more information see API reference.
See the detailed API Reference.
const pattern = `
{
"username": String AND alphanum AND minLength(3) AND maxLength(30),
"password": String AND regex("/^[0-9a-zA-Z]{5,30}$/"),
"access_token"?: String AND Number,
"birthyear": Integer AND range(1900, 2017),
"email": String,
...
}
`;
expect(user).to.matchPattern(pattern);
The above pattern require user
to be an object with keys that satisfy following conditions:
username
password
access_token
birthyear
email
If user
will not satisfy pattern, test will not pass, and you will see error with diff between user
and pattern.
Usage is a two steps process. First, you have to install chai-json-pattern
package.
npm install --save-dev chai-json-pattern
Then import chaiJsonPattern
and use matchPattern
:
import chai, { expect } from 'chai';
import chaiJsonPattern from 'chai-json-pattern';
chai.use(chaiJsonPattern);
expect({ a: 2 }).to.matchPattern(`{
"a": Number AND range(0, 5),
}`);
FAQs
Chai JSON pattern assertions
The npm package @iotcomms.io/chai-json-pattern receives a total of 907 weekly downloads. As such, @iotcomms.io/chai-json-pattern popularity was classified as not popular.
We found that @iotcomms.io/chai-json-pattern demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.