CacheControl / CacheControl/json-rules-engine

Question: Comparing Distinct Arrays of Objects

Aberta
#258 5 comentários 2 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
3.1k
Forks
507
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Nenhum ponto de entrada de arquivo ou teste é nomeado. Comece revisando a condição da regra e o registro de operadores relacionados à avaliação de caminhos de array; use os dois exemplos de facts fornecidos para definir a conclusão como uma correspondência do mesmo objeto que retorna false para o primeiro e true para o segundo.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript
Domínio
backend
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
20/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.