Skip to content

Commit 15d3c69

Browse files
docs(repo): update custom ruleset with multiple thens example (#2208)
1 parent 2db5159 commit 15d3c69

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/guides/4-custom-rulesets.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ rules:
8686

8787
The `then` part of the rule explains which function to apply to the `given` JSONPath. The function you apply [may be one of the core functions](../reference/functions.md) or it may be [a custom function](./5-custom-functions.md).
8888

89-
`then` has two required keywords:
89+
`then` has two main keywords:
9090

9191
```yaml
9292
then:
@@ -115,6 +115,22 @@ responses:
115115
foo: bar
116116
```
117117

118+
You can also have multiple `then`s to target different properties in the same object, or to use different functions. For example, you can have one rule that will check if an object has multiple properties:
119+
120+
```yaml
121+
contact-properties:
122+
description: Contact object must have "name", "url", and "email".
123+
given: $.info.contact
124+
severity: warn
125+
then:
126+
- field: name
127+
function: truthy
128+
- field: url
129+
function: truthy
130+
- field: email
131+
function: truthy
132+
```
133+
118134
### Message
119135

120136
To help you create meaningful messages for results, Spectral comes with a couple of placeholders that are evaluated at runtime.

0 commit comments

Comments
 (0)