-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation_rules_v2.json
More file actions
500 lines (500 loc) · 15.3 KB
/
validation_rules_v2.json
File metadata and controls
500 lines (500 loc) · 15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
{
"version": "2.0",
"description": "Fully declarative validation rules - no hardcoded Python logic required",
"rules": {
"R1.1.1": {
"name": "entry_id_required",
"description": "Entry ID is required and must be non-empty",
"category": "entry_level",
"priority": "critical",
"path": "$.id",
"condition": {
"type": "required"
},
"validation": {
"type": "string",
"minLength": 1
},
"error_message": "Entry ID is required and must be non-empty"
},
"R1.1.2": {
"name": "lexical_unit_required",
"description": "Lexical unit is required and must contain at least one language entry",
"category": "entry_level",
"priority": "critical",
"path": "$.lexical_unit",
"condition": {
"type": "required"
},
"validation": {
"type": "object",
"minProperties": 1
},
"error_message": "Lexical unit is required and must contain at least one language entry"
},
"R1.1.3": {
"name": "sense_required_non_variant",
"description": "At least one sense is required per entry (except for variant entries with variant-type trait)",
"category": "entry_level",
"priority": "critical",
"path": "$.senses",
"condition": {
"type": "conditional",
"when": {
"not": {
"path": "$.relations[*].traits",
"contains": {
"field": "variant-type"
}
}
}
},
"validation": {
"type": "array",
"minItems": 1
},
"error_message": "At least one sense is required per entry",
"validation_mode": "save_only"
},
"R1.2.2": {
"name": "lexical_unit_content_validation",
"description": "Lexical unit content must be non-empty strings",
"category": "entry_level",
"priority": "critical",
"path": "$.lexical_unit.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"error_message": "Lexical unit content cannot be empty or contain only whitespace"
},
"R1.2.3": {
"name": "language_code_validation",
"description": "Lexical unit must contain at least one language",
"category": "entry_level",
"priority": "critical",
"path": "$.lexical_unit",
"condition": {
"type": "if_present"
},
"validation": {
"type": "object",
"minProperties": 1
},
"error_message": "Lexical unit must contain at least one language"
},
"R2.1.1": {
"name": "sense_id_required",
"description": "Sense ID is required and must be non-empty",
"category": "sense_level",
"priority": "critical",
"path": "$.senses[*].id",
"condition": {
"type": "required"
},
"validation": {
"type": "string",
"minLength": 1
},
"error_message": "Sense ID is required and must be non-empty"
},
"R2.1.2": {
"name": "sense_content_or_variant",
"description": "Sense must have definition, gloss, or variant reference",
"category": "sense_level",
"priority": "critical",
"path": "$.senses[*]",
"condition": {
"type": "required"
},
"validation": {
"type": "custom",
"custom_function": "validate_sense_content_or_variant"
},
"error_message": "Sense must have definition, gloss, or be a variant reference"
},
"R2.2.1": {
"name": "definition_content_validation",
"description": "Sense definitions must have at least one non-empty language value",
"category": "sense_level",
"priority": "critical",
"path": "$.senses[*].definition",
"condition": {
"type": "if_present"
},
"validation": {
"type": "object_has_non_empty_value"
},
"error_message": "Sense definition cannot be empty or contain only whitespace"
},
"R2.2.2": {
"name": "gloss_content_validation",
"description": "Sense glosses must have at least one non-empty language value",
"category": "sense_level",
"priority": "critical",
"path": "$.senses[*].gloss.*.text",
"condition": {
"type": "if_present"
},
"validation": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"error_message": "Sense gloss cannot be empty or contain only whitespace"
},
"R2.2.3": {
"name": "example_text_validation",
"description": "Example texts must be non-empty when example is present",
"category": "sense_level",
"priority": "critical",
"path": "$.senses[*].examples[*].text",
"condition": {
"type": "if_present"
},
"validation": {
"type": "string",
"minLength": 1,
"pattern": "\\S+"
},
"error_message": "Example text cannot be empty or contain only whitespace"
},
"R3.1.1": {
"name": "unique_note_types",
"description": "Note types must be unique within entry",
"category": "note_validation",
"priority": "warning",
"path": "$.notes",
"condition": {
"type": "if_present"
},
"validation": {
"type": "object_unique_keys"
},
"error_message": "Duplicate note type found"
},
"R3.2.1": {
"name": "multilingual_note_structure",
"description": "Multilingual notes must be objects with at least one language",
"category": "note_validation",
"priority": "critical",
"path": "$.notes.*",
"condition": {
"type": "if_type",
"value_type": "object"
},
"validation": {
"type": "object",
"minProperties": 1
},
"error_message": "Multilingual note must contain at least one language"
},
"R3.1.2": {
"name": "note_content_validation",
"description": "Note content must be non-empty strings when present",
"category": "note_validation",
"priority": "critical",
"path": "$.notes.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_note_content"
},
"error_message": "Note content cannot be empty"
},
"R4.1.1": {
"name": "pronunciation_language_codes",
"description": "Pronunciation language codes must be valid",
"category": "pronunciation",
"priority": "critical",
"path": "$.pronunciations",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_pronunciation_language_codes",
"allowed_languages": ["pl-fonipa", "en-fonipa", "seh-fonipa", "ipa"]
},
"error_message": "Invalid pronunciation language code"
},
"R4.1.2": {
"name": "ipa_character_validation",
"description": "IPA characters must be from approved character set",
"category": "pronunciation",
"priority": "critical",
"path": "$.pronunciations.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_ipa_characters"
},
"error_message": "Invalid IPA character in pronunciation"
},
"R4.2.1": {
"name": "no_double_stress_markers",
"description": "Double stress markers (ˈˈ or ˌˌ) are not allowed",
"category": "pronunciation",
"priority": "critical",
"path": "$.pronunciations.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_no_double_stress"
},
"error_message": "Double stress markers not allowed"
},
"R4.2.2": {
"name": "no_double_length_markers",
"description": "Double length markers (ːː) are not allowed",
"category": "pronunciation",
"priority": "critical",
"path": "$.pronunciations.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_no_double_length"
},
"error_message": "Double length markers not allowed"
},
"R5.1.1": {
"name": "synonym_antonym_exclusion",
"description": "Entries cannot be both synonym and antonym",
"category": "relation_validation",
"priority": "warning",
"path": "$.relations",
"condition": {
"type": "if_present"
},
"validation": {
"type": "logic",
"operator": "not",
"conditions": [
{
"type": "logic",
"operator": "and",
"conditions": [
{
"type": "array_contains",
"field": "type",
"value": "synonym"
},
{
"type": "array_contains",
"field": "type",
"value": "antonym"
}
]
}
]
},
"error_message": "Entry cannot have both synonym and antonym relations to the same entry"
},
"R5.2.1": {
"name": "subsense_depth",
"description": "Subsense nesting must not exceed 3 levels",
"category": "sense_level",
"priority": "warning",
"path": "$.senses[*]",
"condition": {
"type": "if_present"
},
"validation": {
"type": "max_nesting_depth",
"field": "subsenses",
"max_depth": 3
},
"error_message": "Subsense nesting exceeds maximum depth of 3"
},
"R6.1.1": {
"name": "unique_languages_in_multitext",
"description": "Language codes must be unique in multilingual content",
"category": "general",
"priority": "critical",
"path": "$.senses[*].definition",
"condition": {
"type": "if_type",
"value_type": "object"
},
"validation": {
"type": "object_unique_keys"
},
"error_message": "Duplicate language code found in multilingual content"
},
"R6.1.2": {
"name": "conflicting_sense_pos_requires_manual_entry_pos",
"description": "If senses have conflicting POS values, entry POS must be set manually",
"category": "general",
"priority": "critical",
"path": "$.senses[*]",
"condition": {
"type": "custom"
},
"validation": {
"type": "custom",
"custom_function": "validate_conflicting_pos"
},
"error_message": "Entry must have grammatical_info when senses have conflicting POS"
},
"R7.1.1": {
"name": "date_fields_format",
"description": "Date fields must be in ISO8601 format",
"category": "entry_level",
"priority": "warning",
"path": "$.[date_created,date_modified]",
"condition": {
"type": "if_present"
},
"validation": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}"
},
"error_message": "Date field must be in ISO8601 format (YYYY-MM-DDTHH:MM:SS)"
},
"R8.1.1": {
"name": "no_circular_component_references",
"description": "Component relations must not reference the entry itself",
"category": "relation_validation",
"priority": "critical",
"path": "$.relations[*]",
"condition": {
"type": "custom"
},
"validation": {
"type": "custom",
"custom_function": "validate_no_circular_components"
},
"error_message": "Component relation cannot reference the entry itself (circular reference)"
},
"R8.1.2": {
"name": "no_circular_sense_references",
"description": "Sense relations must not reference senses within the same entry",
"category": "relation_validation",
"priority": "critical",
"path": "$.senses[*].relations[*]",
"condition": {
"type": "custom"
},
"validation": {
"type": "custom",
"custom_function": "validate_no_circular_sense_relations"
},
"error_message": "Sense relation cannot reference a sense within the same entry (circular reference)"
},
"R8.1.3": {
"name": "no_circular_entry_references",
"description": "Entry-level relations must not reference the entry itself",
"category": "relation_validation",
"priority": "critical",
"path": "$.relations[*]",
"condition": {
"type": "custom"
},
"validation": {
"type": "custom",
"custom_function": "validate_no_circular_entry_relations"
},
"error_message": "Entry relation cannot reference the entry itself (circular reference)"
},
"R5.3.1": {
"name": "relation_targets_exist",
"description": "All relation targets must exist in the dictionary",
"category": "relation_validation",
"priority": "critical",
"path": "$.relations[*]",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_relation_targets_exist"
},
"error_message": "Relation target '{value}' does not exist in the dictionary"
},
"S1.1.1": {
"name": "lexical_unit_spelling",
"description": "Validate spelling in lexical unit using hunspell",
"category": "spelling",
"priority": "warning",
"path": "$.lexical_unit.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_hunspell_spelling",
"lang_code": "en_US",
"auto_detect_languages": true,
"minWordLength": 3,
"ignoreWords": ["test", "demo", "example"]
},
"error_message": "Spelling error detected in lexical unit"
},
"S1.1.2": {
"name": "definition_spelling",
"description": "Validate spelling in definitions using hunspell",
"category": "spelling",
"priority": "informational",
"path": "$.senses[*].definition.*",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_hunspell_spelling",
"lang_code": "en_US",
"auto_detect_languages": true,
"minWordLength": 3
},
"error_message": "Spelling error in definition"
},
"S1.1.3": {
"name": "gloss_spelling",
"description": "Validate spelling in glosses using hunspell",
"category": "spelling",
"priority": "informational",
"path": "$.senses[*].gloss.*.text",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_hunspell_spelling",
"lang_code": "en_US",
"auto_detect_languages": true,
"minWordLength": 3
},
"error_message": "Spelling error in gloss"
},
"S1.1.4": {
"name": "note_spelling",
"description": "Validate spelling in notes using hunspell",
"category": "spelling",
"priority": "informational",
"path": "$.notes[*].text",
"condition": {
"type": "if_present"
},
"validation": {
"type": "custom",
"custom_function": "validate_hunspell_spelling",
"lang_code": "en_US",
"auto_detect_languages": true,
"minWordLength": 3
},
"error_message": "Spelling error in note"
}
}
}