Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quantifiers for allOf or anyOf operators #1423

Closed
BernieWhite opened this issue Feb 4, 2023 · 0 comments · Fixed by #1525
Closed

Add quantifiers for allOf or anyOf operators #1423

BernieWhite opened this issue Feb 4, 2023 · 0 comments · Fixed by #1525
Assignees
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables
Milestone

Comments

@BernieWhite
Copy link
Member

BernieWhite commented Feb 4, 2023

When processing allOf or anyOf operators we may want to determine if a specific quantity of results passed when enumerating through a field.

With greaterOrEqual:

{
  "field": "properties.logs[*]",
  "anyOf": [],
  "greaterOrEquals": 1
}

With count:

{
  "field": "properties.logs[*]",
  "anyOf": [],
  "count": 1
}

As shown anyOf will enumerate through properties.log[*]. The number of items that return true will be counted.

As is the normal behaviour for PSRule, greaterOrEqual will return true if the number of items is greater or equal to the number specified. Where as count will return true if the number of items is the exact number.

Items are only counted if the inner conditions of anyOf or allOf return true.

@BernieWhite BernieWhite added enhancement New feature or request feature: language Issues that affect language such keywords and variables labels Feb 4, 2023
@BernieWhite BernieWhite self-assigned this Feb 4, 2023
@BernieWhite BernieWhite added this to the v2.9.0 milestone May 6, 2023
BernieWhite added a commit to BernieWhite/PSRule that referenced this issue May 7, 2023
@BernieWhite BernieWhite mentioned this issue Jun 8, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: language Issues that affect language such keywords and variables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant