
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@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 0 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.