How to handle array of objects?

Open
#421 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

Start by reproducing the rule against the equipmentList facts shown in the issue, including the JSONPath filter and notEqual comparison. Check whether the package supports matching nested objects inside arrays and whether the result should identify embroidery with speed 250. Done means the documented use case behaves as expected or the limitation is clearly established.

Written by the indexing model from the issue text.

Description

Usecase: Is there any equipment with type embroidery and setting speed 250?

Fact:

const facts = {
	equipmentList: [
		{ type: 'embroidery', setting: { speed: 250 } },
		{ type: 'sewing', setting: { speed: 150 } },
	],
	substrate: { color: { hexcode: '#FFFFFF' } },
	Size: 'S',
};

// the following IS NOT working as expected. no matter what 'setting.speed' I give, I am getting true for the condition

{
  "all": [
    {
      "fact": "equipmentList",
      "path": "$[?(@.type == 'sewing' && @.setting.speed == 250)]",
      "operator": "notEqual",
      "value": []
    },
  ]
}

Does the package support this kind of a usecase?

Dominant language
JavaScript
Stars
3.1k
Forks
507
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CacheControl/json-rules-engine

All issues in CacheControl/json-rules-engine

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.