{"id":31947362,"url":"https://github.com/naman03malhotra/match-rules","last_synced_at":"2025-10-14T11:33:58.019Z","repository":{"id":40768280,"uuid":"262560578","full_name":"naman03malhotra/match-rules","owner":"naman03malhotra","description":"A tiny 1kB zero dependency JavaScript utility that lets you write your conditional business logic in a declarative way  (React like).","archived":false,"fork":false,"pushed_at":"2023-01-06T05:59:23.000Z","size":1299,"stargazers_count":43,"open_issues_count":16,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-07T07:11:25.320Z","etag":null,"topics":["complex-conditions","complex-rules","conditional-statements","declarative","declarative-programming","if-else","if-else-refactoring","imperative","imperative-programming","javascript-utility","npm-module","react","reactjs"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/match-rules","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naman03malhotra.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-09T11:56:16.000Z","updated_at":"2024-01-28T05:41:08.000Z","dependencies_parsed_at":"2023-02-05T11:46:47.534Z","dependency_job_id":null,"html_url":"https://github.com/naman03malhotra/match-rules","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/naman03malhotra/match-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naman03malhotra%2Fmatch-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naman03malhotra%2Fmatch-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naman03malhotra%2Fmatch-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naman03malhotra%2Fmatch-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naman03malhotra","download_url":"https://codeload.github.com/naman03malhotra/match-rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naman03malhotra%2Fmatch-rules/sbom","scorecard":{"id":673485,"data":{"date":"2025-08-11","repo":{"name":"github.com/naman03malhotra/match-rules","commit":"f2eff3877063b06da3e72e82bbb216fbc4b06879"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CD.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CD.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CD.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CD.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CD.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CD.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CI.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CI.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/CI.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/naman03malhotra/match-rules/CI.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/CD.yml:1","Warn: no topLevel permission defined: .github/workflows/CI.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: MIT-LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: MIT-LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"30 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T20:53:21.169Z","repository_id":40768280,"created_at":"2025-08-21T20:53:21.170Z","updated_at":"2025-08-21T20:53:21.170Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013446,"owners_count":26085274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["complex-conditions","complex-rules","conditional-statements","declarative","declarative-programming","if-else","if-else-refactoring","imperative","imperative-programming","javascript-utility","npm-module","react","reactjs"],"created_at":"2025-10-14T11:31:01.945Z","updated_at":"2025-10-14T11:33:57.994Z","avatar_url":"https://github.com/naman03malhotra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# match-rules\n\nA tiny (1kB GZipped) zero dependency JavaScript utility that lets you write your conditional business logic in a declarative way (React like).\n\nIt can be used with feature flags, complex conditions, conditional rendering, and the rest is your imagination.\n\n_**I wrote a [detailed blog post](https://dev.to/naman03malhotra/declaring-your-business-logic-like-react-9d9), please do read it to understand the thought process in depth (5 mins tops).**_\n\n### Install\n\n[![Build Status](https://github.com/naman03malhotra/match-rules/workflows/CI/badge.svg?branch=master)](https://github.com/naman03malhotra/match-rules/actions)\n[![Build Status](https://github.com/naman03malhotra/match-rules/workflows/CD/badge.svg?branch=v1.3.8)](https://github.com/naman03malhotra/match-rules/actions)\n[![Coverage Status](https://coveralls.io/repos/github/naman03malhotra/match-rules/badge.svg?branch=master\u0026kill_cache=1)](https://coveralls.io/github/naman03malhotra/match-rules?branch=master\u0026kill_cache=1)\n[![npm](https://img.shields.io/npm/dm/match-rules)](https://www.npmjs.com/package/match-rules)\n![npm](https://img.shields.io/npm/dt/match-rules)\n![NPM](https://img.shields.io/npm/l/match-rules)\n[![npm](https://img.shields.io/npm/v/match-rules)](https://www.npmjs.com/package/match-rules)\n[![DeepScan grade](https://deepscan.io/api/teams/11791/projects/14725/branches/280135/badge/grade.svg)](https://deepscan.io/dashboard#view=project\u0026tid=11791\u0026pid=14725\u0026bid=280135)\n\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/match-rules?label=GZipped\u0026style=for-the-badge)](https://bundlephobia.com/result?p=match-rules)\n\nThrough Yarn\n`yarn add match-rules`\n\nThrough npm\n`npm install match-rules --save`\n\n### Usage\n\nES6\n\n```js\nimport matchRules from \"match-rules\";\n```\n\nES5\n\n```js\nconst matchRules = require(\"match-rules\").default;\n```\n\nTypeScript\n\n```js\nimport matchRules from \"match-rules\";\n```\n\n### API\n\n```js\n// returns a boolean value.\nmatchRules(\n  sourceObject, // can be any object with data.\n  RULES_OBJECT, // you can also pass multiple rules in an array [RULE_ONE, RULE_TWO],\n  options // (optional)\n);\n\nconst options = {\n  operator: \"and\", // (optional, default: 'and') in case of multiple rules you can pass 'and' or 'or'. In case of 'or' your rules will be compared with 'or' operator. Default is 'and'\n  debug: true, // (optional, default: false) when debug is true, it logs a trace object which will tell you which rule failed and with what values of source and rules object.\n};\n\n// NOTE: all the rules inside a single rule are concatenated by 'and' operator.\n```\n\n### Live Playground\n\n[Live Example on Stackblitz](https://stackblitz.com/edit/match-rules)\n\n### Server Side\n\nThis module can be used with Node as well.\n\n### Example (Usecase)\n\n```js\n// rules object\nimport matchRules from \"match-rules\";\n\nconst SHOW_JOB_RULE = {\n  hasVisa: true,\n  profile: {\n    country: \"US\",\n    yearsOfExperience: (exp, sourceObject) =\u003e exp \u003e 3,\n  },\n};\n\n// source object\nconst user = {\n  username: \"someName\",\n  hasVisa: true,\n  profile: {\n    country: \"US\",\n    yearsOfExperience: 5,\n    yearOfGraduation: 2011,\n  },\n};\n\n// pass source and rules\nif (matchRules(user, SHOW_JOB_RULE)) {\n  //... do something conditionally.\n}\n```\n\n### Features\n\n- **Multiple rules support** - you can pass multiple rules dealing with a common source object.\n\n- **Graceful exit** - returns false if the asked property in the rule doesn’t exist in the source object.\n\n- **Debugging** - when enabled logs a trace object for all the keys in the rule with a meaningful message of what went wrong.\n\n- **Function support** - you can pass custom functions in the rule for handling complex conditions.\n\n- **Nested Rules** - you can pass a rule no matter how deep your data source is.\n\n- **Multiple operator support** - you can pass or / and operators in case of multiple rules.\n  Dillinger is a cloud-enabled, mobile-ready, offline-storage, AngularJS powered HTML5 Markdown editor.\n\n### Why would you want to use it in your projects.\n\n- Reduces cognitive complexity.\n\n- Easy to maintain, declarative in nature.\n\n- Code is more readable, you can separate conditional logic in a `rules.js` file.\n\n- You do not have to write unit tests for those conditions individually, just take a snapshot at max.\n\n- Reduce code redundancy (you can compose and extend rules).\n\n- You do not have to traverse nested objects, just write your rules with the same structure.\n\n- Any conditional (complex) case can be handled using a function.\n\n- Easily manage your AB testing logic.\n\n### Function Support:\n\n#### So far it is capable to handle any condition since you can write your own functions in the rule.\n\nwhen it encounters a function it passes the value (as the first parameter) and original source object (as the second parameter) from the source to that function matching the corresponding key of that level.\n\nUsing a combination of key's value and original source object you can handle complex conditions.\n\nFor example:\n\n```js\nconst SHOW_ADS_RULES = {\n  profile: {\n    age: (value, sourceObject) =\u003e\n      value \u003e 18 \u0026\u0026 value \u003c 55 \u0026\u0026 sourceObject.admin === true,\n  },\n};\n\nconst source = {\n  profile: {\n    age: 20,\n  },\n  admin: true,\n};\n\n// so value of 20 (First param) and complete source object (Second Param) will be passed to that function.\n// NOTE: you should always return boolean value from the function you implement.\n```\n\n### Extending Rules (avoid redundancy)\n\n```js\nconst SHOW_ADS_RULES = {\n  onboarding: true,\n  admin: false,\n  profile: {\n    country: \"US\",\n    school: \"MIT\",\n    age: (value) =\u003e value \u003e 18 \u0026\u0026 value \u003c 55,\n  },\n};\n\n// show a different Ad if the country is India.\nconst SHOW_ADS_RULES_INDIA = {\n  ...SHOW_ADS_RULES,\n  profile: {\n    ...SHOW_ADS_RULES.profile,\n    country: \"India\",\n  },\n};\n```\n\n### More examples\n\n**Ex 1. Feature Flags**\n\n```js\nimport matchRules from \"match-rules\";\n\n// this object can come from your app state\nconst sourceObject = {\n  enable_unique_feature: true,\n  when_user_is_admin: true,\n  age_more_than_18: 25,\n};\n\n// Rule\nconst ENABLE_UNIQUE_FEATURE = {\n  enable_unique_feature: true,\n  when_user_is_admin: true,\n  age_more_than_18: (value, sourceObject) =\u003e value \u003e 18,\n};\n\nif (matchRules(sourceObject, ENABLE_UNIQUE_FEATURE)) {\n  // render unique feature\n}\n```\n\n**Ex 2. Multiple Rules and functions implementation**\n\n```js\nimport matchRules from \"match-rules\";\n\n// this object can come from your app state\nconst sourceObject = {\n  enable_unique_feature: true,\n  profile: {\n    age: 18,\n  },\n};\n\n// Rules\nconst ENABLE_UNIQUE_FEATURE = {\n  enable_unique_feature: true,\n};\n\nconst ENABLE_UNIQUE_FEATURE_WITH_AGE_18YO = {\n  profile: {\n    age: (value, sourceObject) =\u003e value \u003e 18,\n  },\n};\n\n// by default multiple rules will be combined using AND operator\nif (\n  matchRules(sourceObject, [\n    ENABLE_UNIQUE_FEATURE,\n    ENABLE_UNIQUE_FEATURE_WITH_AGE_18YO,\n  ])\n) {\n  // render unique feature\n}\n```\n\n**Ex 3. Multiple Rules using OR operator**\n\n```js\nimport matchRules from \"match-rules\";\n\n// this object can come from your app state\nconst sourceObject = {\n  enable_unique_feature: true,\n  profile: {\n    age: 18,\n    country: \"US\",\n  },\n};\n\n// Rules\nconst ENABLE_UNIQUE_FEATURE_FOR_US = {\n  profile: {\n    country: \"US\",\n  },\n};\n\nconst ENABLE_UNIQUE_FEATURE_FOR_INDIA = {\n  profile: {\n    country: \"IN\",\n  },\n};\n\n// to combine rules using OR, (display feature if user is from US or INDIA)\nif (\n  matchRules(\n    sourceObject,\n    [ENABLE_UNIQUE_FEATURE_FOR_US, ENABLE_UNIQUE_FEATURE_FOR_INDIA],\n    { operator: \"or\" }\n  )\n) {\n  // render unique feature\n}\n\n// you can pass as many rules you want\n```\n\n**Ex 4. using functions**\n\n```js\nimport matchRules from \"match-rules\";\n\n// this object can come from your app state\nconst sourceObject = {\n  enable_unique_feature: true,\n  profile: {\n    age: 18,\n    country: \"US\",\n  },\n};\n\n// Rules\nconst ENABLE_UNIQUE_FEATURE_FOR_US_OR_INDIA = {\n  profile: {\n    country: (value, sourceObject) =\u003e value === \"US\" || value === \"IN\",\n  },\n};\n\n// to combine rules using OR, (display feature if user is from US or INDIA)\nif (matchRules(sourceObject, ENABLE_UNIQUE_FEATURE_FOR_US_OR_INDIA)) {\n  // render unique feature\n}\n\n// you can use functions to deal with complex scenarios\n```\n\n**Ex 5. Rule for deep source objects**\n\n```js\nimport matchRules from \"match-rules\";\n\n// this object can come from your app state\nconst sourceObject = {\n  enable_unique_feature: true,\n  userData: {\n    personalData: {\n      profile: {\n        age: 18,\n        country: \"US\",\n      },\n    },\n  },\n};\n\n// Rules\nconst ENABLE_UNIQUE_FEATURE_FOR_US_OR_INDIA = {\n  userData: {\n    personalData: {\n      profile: {\n        country: (value, sourceObject) =\u003e value === \"US\" || value === \"IN\",\n      },\n    },\n  },\n};\n\n// to combine rules using OR, (display feature if user is from US or INDIA)\nif (matchRules(sourceObject, ENABLE_UNIQUE_FEATURE_FOR_US_OR_INDIA)) {\n  // render unique feature\n}\n// you can use functions to deal with complex scenarios\n```\n\n**Ex 6. Dynamic Rules | RULES as functions**\n\n```js\n// example where you have to match the dynamically generated rule\nconst dataFromServer = {\n  user_id: 123, // created by user\n  item_id: '87df83b',\n  item_type: 'Post'\n}\n\nconst userSource = {\n  id: 123,\n}\n\nconst DYNAMIC_USER_RULE = (itemCreatedByUserParam) =\u003e {\n  return {\n    id: itemCreatedByUserParam.user_id,\n  }\n}\n\nif(matchRules(userSource, DYNAMIC_USER_RULE(dataFromServer)) {\n // show edit option to creator of this post\n}\n```\n\n## Debugging\n\nwhen enabled logs a trace object for all the keys in the rule with a meaningful message of what went right and wrong.\n\n```js\nmatchRules(sourceObject, RULES, { debug: true })\n\n// sample trace object\n{\n  \"0\": {\n    \"company\": {\n      \"enable_feature\": {\n        \"enable_feature_for_user\": {\n          \"value\": true,\n          \"message\": \"Value equated for the given rule, Rule data: true (type: boolean), Source data: true (type: boolean)\"\n        }\n      },\n      \"enable_people_management\": {\n        \"value\": true,\n        \"message\": \"Value equated for the given rule, Rule data: true (type: boolean), Source data: true (type: boolean)\"\n      }\n    },\n    \"company_admin\": {\n      \"value\": true,\n      \"message\": \"Value equated for the given rule, Rule data: true (type: boolean), Source data: true (type: boolean)\"\n    },\n    \"enable_special_feature\": {\n      \"value\": true,\n      \"message\": \"Value equated for the given rule, Rule data: false (type: boolean), Source data: false (type: boolean)\"\n    },\n    \"temp\": {\n      \"value\": false,\n      \"message\": \"Function was executed for the given rule with value: 3 (type: number)\"\n    }\n  }\n}\n```\n\n## Development\n\nFor development, please make the changes in the code and write appropriate unit test case.\nFeel free to send across a Pull Request if it doesn't fit your use-case.\n\n## Zero dependency library\n\n`match-rules` does not have any dependency, it is just 1kB (GZipped) in size.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaman03malhotra%2Fmatch-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaman03malhotra%2Fmatch-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaman03malhotra%2Fmatch-rules/lists"}