-
Notifications
You must be signed in to change notification settings - Fork 1
/
traitsRules.json
79 lines (79 loc) · 2.46 KB
/
traitsRules.json
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
{
"$schema": "./jsontronRulesSchema.json",
"schema": {
"title": "Traits Rules",
"id": "TraitsRules",
"schemaVersion": "1.0",
"queryBinding": "jsonpath",
"defaultPhase": "default",
"phase": [
{
"id": "default",
"active": [
"UniqueIdCheck",
"IdReferenceCheck"
]
}
],
"pattern": [
{
"id": "UniqueIdCheck",
"title": "Unique Id Check",
"abstract": false,
"rule": [
{
"id": "UniqueIdCheck_R1",
"context": "$",
"assert": [
{
"id": "UniqueIdCheck_R1_A1",
"test": "jp.query(contextNode, '$..traits.*.id').length == new Set(jp.query(contextNode, '$..traits.*.id')).size",
"message": "Global: The id of a trait must be unique."
}
]
},
{
"id": "UniqueIdCheck_R2",
"context": "$..traits.*",
"assert": [
{
"id": "UniqueIdCheck_R2_A1",
"test": "jp.query(contextNode, '$..features.*.id').length == new Set(jp.query(contextNode, '$..features.*.id')).size",
"message": "'Trait [' + jp.query(contextNode, '$.*.id') + ']: The id of a feature must be unique.'"
}
]
},
{
"id": "UniqueIdCheck_R3",
"context": "$..features.*",
"assert": [
{
"id": "UniqueIdCheck_R3_A1",
"test": "jp.query(contextNode, '$..enums.*.id').length == new Set(jp.query(contextNode, '$..enums.*.id')).size",
"message": "'Feature [' + jp.query(contextNode, '$.*.id') + ']: The id of an enum must be unique.'"
}
]
}
]
},
{
"id": "IdReferenceCheck",
"title": "Check whether all referenced id are defined.",
"abstract": false,
"rule": [
{
"id": "IdReferenceCheck_R1",
"context": "$..features.*",
"assert": [
{
"id": "IdReferenceCheck_R1_A1",
"test": "jp.query(contextNode, '$..enums.*.id').includes(jp.query(contextNode, '$.*.default')[0])",
"message": "'Feature [' + jp.query(contextNode, '$.*.id') + ']: The default ' + jp.query(contextNode, '$.*.default')[0] + ' is not defined.'"
}
]
}
]
}
]
}
}