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

docs(rulesets): pattern function can have delimeters #2579

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions docs/reference/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,26 @@ Regular expressions!
| match | if provided, value must match this regex | `string` | no |
| notMatch | if provided, value must _not_ match this regex | `string` | no |

The regex pattern provided can be just the pattern itself (e.g.: `"[a-z]"`) or you can include start/end delimiters if you would like to use regex modifiers like `/i` (e.g.: `"/[a-z]/i"`).

<!-- title: example -->

```yaml
no-x-headers:
message: "Header {{property}} should not start with `X-`."
given: "$..parameters[?(@.in === 'header')].name"
then:
function: pattern
functionOptions:
notMatch: "/^x-/i"

path-no-trailing-slash:
description: Paths should not end with `#/`.
description: "Paths should not end with `/`."
given: "$.paths[*]~"
then:
function: pattern
functionOptions:
notMatch: ".+\/$"
notMatch: "\/$"
```

## casing
Expand Down