Skip to content

Commit

Permalink
docs(rulesets): pattern function can have delimeters
Browse files Browse the repository at this point in the history
fixes #2578 - this was already possible, just not documented.
  • Loading branch information
philsturgeon committed Jan 22, 2024
1 parent 96eee89 commit c9ca3ed
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit c9ca3ed

Please sign in to comment.