
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
@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 838 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.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.