
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@unly/conditions-matcher
Advanced tools
Compares a given context with a filter (a set of conditions) and resolves whether the context checks the filter. Strongly inspired by [GraphQL filters](https://www.prisma.io/docs/reference/prisma-api/queries-ahwee4zaey#filtering-by-field).
Compares a given context with a filter (a set of conditions) and resolves whether the context checks the filter. Strongly inspired by GraphQL filters.
Use cases are:
The biggest strengths of this plugin are:
contains, endsWith, greaterThan, etc.).This package was developed after opening a StackOverflow question, we were disappointed not to find an existing implementation and therefore built our own.
Using npm :
npm i @unly/conditions-matcher
Using yarn :
yarn add @unly/conditions-matcher
ES5
const contextMatcher = require("@unly/conditions-matcher");
ES6
import contextMatcher from "@unly/conditions-matcher";
See the examples for more details, clone the project to play around with those. Then please check the conditional operators documentation here
const result: boolean = contextMatcher(filter, context, options);
filter: Contains all the conditions that constitute the said filter. For a complete list of conditions and operators, see the documentation. Example :
const filter = {
AND: [
{ "school_gpa__lessThan": 3 },
{ "school_name__contains": "business" },
{ "foo__eq": "bar" },
],
};
context: Is an object containing the data (context) to match against the filter, to know whether it passes the conditions or not. Example :
const context = {
'school': {
name: 'Awesome business school',
gpa: 2.5
},
};
options: Optional configuration object.
This example will return the following in result:
{
status: true, // Means the check passed, the context therefore passes the filter's conditions
ignoredConditions: [ // Contains conditions that were ignored due to a lack of data in `context`
{
status: null, // "null" because no check could be performed (lack of data)
rule: 'foo__eq',
conditionalOperator: 'eq',
path: 'foo',
valueInContext: undefined,
reason: 'Error: path: foo is not defined in context' // Human friendly error message, easier to reason about
}
],
}
See defaultOptions.
| Option name | Default value | Description |
|---|---|---|
strictMatch | false | This represents the behavior in case of non-existent context corresponds to the filter. Set to true if you want to return false in case of a value in the filter doesn't exist. |
We gladly accept PRs, but please open an issue first so we can discuss it beforehand.
yarn start # Shortcut - Runs linter + build + tests in concurrent mode (watch mode)
OR run each process separately for finer control
yarn lint
yarn build
yarn test
yarn test # Run all tests, interactive and watch mode
yarn test:once # Used for CI/CD
yarn test:coverage # Generate coverage report
We use Semantic Versioning for this project: https://semver.org/. (vMAJOR.MINOR.PATCH: v1.0.1)
Note: You should write the CHANGELOG.md doc before releasing the version. This way, it'll be included in the same commit as the built files and version update
Then, release a new version:
yarn run releaseThis command will prompt you for the version to update to, create a git tag, build the files and commit/push everything automatically.
Don't forget we are using SemVer, please follow our SemVer rules.
Pro hint: use beta tag if you're in a work-in-progress (or unsure) to avoid releasing WIP versions that looks legit
yarn releaseAndPublish # Shortcut - Will prompt for bump version, commit, create git tag, push commit/tag and publish to NPM
yarn release # Will prompt for bump version, commit, create git tag, push commit/tag
npm publish # Will publish to NPM
MIT
FAQs
Compares a given context with a filter (a set of conditions) and resolves whether the context checks the filter. Strongly inspired by [GraphQL filters](https://www.prisma.io/docs/reference/prisma-api/queries-ahwee4zaey#filtering-by-field).
We found that @unly/conditions-matcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.