Skip to content

Commit

Permalink
docs(repo): update custom ruleset with multiple thens example (#2208)
Browse files Browse the repository at this point in the history
  • Loading branch information
heitortsergent committed Jul 19, 2022
1 parent 2db5159 commit 15d3c69
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/guides/4-custom-rulesets.md
Expand Up @@ -86,7 +86,7 @@ rules:

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).

`then` has two required keywords:
`then` has two main keywords:

```yaml
then:
Expand Down Expand Up @@ -115,6 +115,22 @@ responses:
foo: bar
```

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:

```yaml
contact-properties:
description: Contact object must have "name", "url", and "email".
given: $.info.contact
severity: warn
then:
- field: name
function: truthy
- field: url
function: truthy
- field: email
function: truthy
```

### Message

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

0 comments on commit 15d3c69

Please sign in to comment.