Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Question: Comparing Distinct Arrays of Objects

未关闭
#258 5 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
backend

调研方向

未指定文件或测试入口点。首先检查与数组路径求值相关的规则条件和运算符注册表;使用提供的两个 facts 示例,将完成定义为同一对象匹配:第一个返回 false,第二个返回 true。

由索引模型根据 Issue 内容生成。

描述

Hello,

I am trying to compare an array of objects to check for a specific set of objects to be present in any of them, but not across all of them, specifically lets take this rule:

const arrayRule = {
        conditions: {
            any: [
                {
                    all: [
                        {
                            fact: 'data',
                            path: '$.[*].equalityTest',
                            operator: 'equal',
                            value: 50,
                        },
                        {
                            fact: 'data',
                            path: '$.[*].anotherTest',
                            operator: 'equal',
                            value: 50,
                        },
                    ],
                },
            ],
        },
        event: {
            type: 'arrayRule',
        },
    };

This is the first iteration of the rule I came up with, it is incorrect, but I wanted to give an idea of what I am aiming for.

Specifically here, we have a rule where I want equalityTest to equal 50 and anotherTest to also equal 50. But I want them to equal those values in the same object, such that:
THIS SHOULD RETURN FALSE

 const facts = {
                data: [
                    {
                        anotherIntegerFact: 1,
                        equalityTest: 50,
                    },
                    {
                        anotherIntegerFact: 50,
                        equalityTest: 40,
                    },
                ],
            };

THIS SHOULD RETURN TRUE

 const facts = {
                data: [
                    {
                        anotherIntegerFact: 50,
                        equalityTest: 50,
                    },
                    {
                        anotherIntegerFact: 40,
                        equalityTest: 40,
                    },
                ],
            };

Would love any suggestions or ideas on a way to tackle this. One thought was I could write my own operator and add it to the registry of operators on our end, but before I did so, I wanted to validate that is needed.

Thanks

主要语言
JavaScript
星标
3.1k
派生
507
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CacheControl/json-rules-engine 的其他 Issue

查看 CacheControl/json-rules-engine 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。