You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/checks_config.md
+47-16Lines changed: 47 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This documentation explains the schema and configuration format for creating met
4
4
5
5
## Overview
6
6
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.
8
8
9
9
## Rule Configuration
10
10
@@ -30,13 +30,15 @@ A rule configuration is a dictionary with the following structure:
30
30
}
31
31
```
32
32
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.
34
34
35
35
## Expression Types
36
36
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
+
37
39
### 1. Field Expression
38
40
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.
40
42
41
43
```python
42
44
{
@@ -127,21 +129,30 @@ Here's a complete example showing multiple rules with different expression types
127
129
"id": "license:exists",
128
130
"level": "error",
129
131
"title": "Record license",
132
+
"message": "Licenses are required.",
133
+
"description": "All submissions must specify the licensing terms.",
130
134
"checks": [
131
135
{
132
136
"path": "metadata.rights",
133
137
"type": "list",
134
138
"operator": "exists",
135
139
"predicate": {}
136
140
}
137
-
],
138
-
"message": "Licenses are required.",
139
-
"description": "All submissions must specify the licensing terms."
141
+
]
140
142
},
141
143
{
142
144
"id": "creators:identifier",
143
145
"level": "info",
144
146
"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
+
},
145
156
"checks": [
146
157
{
147
158
"path": "metadata.creators",
@@ -167,17 +178,37 @@ Here's a complete example showing multiple rules with different expression types
167
178
]
168
179
}
169
180
}
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
+
]
180
182
},
181
183
]
182
184
}
183
185
```
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)",
0 commit comments