Skip to content

Commit e80a739

Browse files
carlinmackslint
andcommitted
fix: Apply suggestions from code review
Co-authored-by: Alex Ioannidis <[email protected]>
1 parent bb3805c commit e80a739

File tree

1 file changed

+47
-16
lines changed

1 file changed

+47
-16
lines changed

docs/reference/checks_config.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This documentation explains the schema and configuration format for creating met
44

55
## Overview
66

7-
The system provides a flexible way to define validation rules for record metadata using JSON stored in the database. Rules can check individual fields, compare values, and validate lists of items with complex conditions. This schema provides a powerful way to define complex validation logic while remaining human-readable and maintainable.
7+
The system provides a flexible way to define validation rules for record metadata using JSON stored in the database. Rules can check individual fields, compare values, and validate lists of items with complex conditions. This schema provides a powerful way to define complex validation logic while staying human-readable and maintainable.
88

99
## Rule Configuration
1010

@@ -30,13 +30,15 @@ A rule configuration is a dictionary with the following structure:
3030
}
3131
```
3232

33-
This object is stored in the `params` section of the check_config in the database.
33+
This object is stored in the `params` section of the `CheckConfig` model in the database.
3434

3535
## Expression Types
3636

37+
In order to describe the rules which make up a check or condition, we have created a grammar of **expressions** which can be composed in JSON. An expression is a structured, logical unit which can 1. contain expressions and 2. be evaluated. It can be thought of as how you might compose an Excel cell formula, where each cell reference or function is an expression. We start from the most basic expression, the `field.`
38+
3739
### 1. Field Expression
3840

39-
Accesses a fiel, or nested field, from the metadata using dot notation, returning that value to the check.
41+
Accesses a field from the metadata using dot notation, returning that value.
4042

4143
```python
4244
{
@@ -127,21 +129,30 @@ Here's a complete example showing multiple rules with different expression types
127129
"id": "license:exists",
128130
"level": "error",
129131
"title": "Record license",
132+
"message": "Licenses are required.",
133+
"description": "All submissions must specify the licensing terms.",
130134
"checks": [
131135
{
132136
"path": "metadata.rights",
133137
"type": "list",
134138
"operator": "exists",
135139
"predicate": {}
136140
}
137-
],
138-
"message": "Licenses are required.",
139-
"description": "All submissions must specify the licensing terms."
141+
]
140142
},
141143
{
142144
"id": "creators:identifier",
143145
"level": "info",
144146
"title": "Creator Identifiers",
147+
"message": "Affiliations are recommended for all creators",
148+
"description": "All creators should have a persistent identifier (e.g. an ORCID)",
149+
"condition": {
150+
"path": "metadata.creators",
151+
"type": "list",
152+
"operator": "exists",
153+
"predicate": {
154+
}
155+
},
145156
"checks": [
146157
{
147158
"path": "metadata.creators",
@@ -167,17 +178,37 @@ Here's a complete example showing multiple rules with different expression types
167178
]
168179
}
169180
}
170-
],
171-
"message": "Affiliations are recommended for all creators (e.g. an ORCID)",
172-
"condition": {
173-
"path": "metadata.creators",
174-
"type": "list",
175-
"operator": "exists",
176-
"predicate": {
177-
}
178-
},
179-
"description": "All creators should have a persistent identifier (e.g. an ORCID)"
181+
]
180182
},
181183
]
182184
}
183185
```
186+
187+
If these checks fail for a draft or record, the following error messages will be returned in the draft
188+
189+
```javascript
190+
"errors": [
191+
{
192+
"field": "metadata.rights",
193+
"messages": [
194+
"Licenses are required."
195+
],
196+
"description": "All submissions must specify the licensing terms.",
197+
"severity": "error",
198+
"context": {
199+
"community": "<community-uuid>"
200+
}
201+
},
202+
{
203+
"field": "metadata.creators",
204+
"messages": [
205+
"Affiliations are recommended for all creators"
206+
],
207+
"description": "All creators should have a persistent identifier (e.g. an ORCID)",
208+
"severity": "info",
209+
"context": {
210+
"community": "<community-uuid>"
211+
}
212+
},
213+
],
214+
```

0 commit comments

Comments
 (0)