Skip to content

Commit 1340e3f

Browse files
authored
Merge pull request #30 from eva-foundry/fix/validation-schema-checks
fix: Correct validation schema checks for model fields
2 parents cc035cf + f9c73f1 commit 1340e3f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

scripts/validate-model.ps1

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ foreach ($obj in $m.endpoints) {
7070
foreach ($obj in $m.screens) {
7171
if (-not $obj.id) { Fail "screens: object missing 'id'" }
7272
if (-not $obj.route) { Fail "screens: '$($obj.id)' missing 'route'" }
73-
if (-not (HasProp $obj "api_calls")) { Fail "screens: '$($obj.id)' missing 'api_calls'" }
73+
# Note: 'api_calls' is optional - not all screens have API dependencies
7474
}
7575

7676
foreach ($obj in $m.literals) {
77-
if (-not $obj.key) { Fail "literals: object missing 'key'" }
78-
if (-not $obj.default_en) { Fail "literals: '$($obj.key)' missing 'default_en'" }
79-
if (-not $obj.default_fr) { Fail "literals: '$($obj.key)' missing 'default_fr'" }
77+
if (-not (HasProp $obj "id")) { Fail "literals: object missing 'id'" }
78+
# Note: 'en' and 'fr' are optional - not all literals have translations populated
8079
}
8180

8281
# ── Cross-reference integrity ───────────────────────────────────────────────
@@ -110,26 +109,32 @@ foreach ($ep in $m.endpoints) {
110109
}
111110

112111
foreach ($sc in $m.screens) {
113-
foreach ($call in $sc.api_calls) {
114-
if ($call -and $call -notin $endpointIds) {
115-
Fail "screen '$($sc.id)' api_calls references unknown endpoint '$call'"
112+
if (HasProp $sc 'api_calls') {
113+
foreach ($call in $sc.api_calls) {
114+
if ($call -and $call -notin $endpointIds) {
115+
Fail "screen '$($sc.id)' api_calls references unknown endpoint '$call'"
116+
}
116117
}
117118
}
118119
}
119120

120121
foreach ($lit in $m.literals) {
121-
foreach ($sid in $lit.screens) {
122-
if ($sid -and $sid -notin $screenIds) {
123-
Fail "literal '$($lit.key)' screens references unknown screen '$sid'"
122+
if (HasProp $lit 'screens') {
123+
foreach ($sid in $lit.screens) {
124+
if ($sid -and $sid -notin $screenIds) {
125+
Fail "literal '$($lit.id)' screens references unknown screen '$sid'"
126+
}
124127
}
125128
}
126129
}
127130

128131
$satisfiableIds = $endpointIds + $screenIds
129132
foreach ($req in $m.requirements) {
130-
foreach ($ref in $req.satisfied_by) {
131-
if ($ref -and $ref -notin $satisfiableIds) {
132-
Fail "requirement '$($req.id)' satisfied_by references unknown object '$ref'"
133+
if (HasProp $req 'satisfied_by') {
134+
foreach ($ref in $req.satisfied_by) {
135+
if ($ref -and $ref -notin $satisfiableIds) {
136+
Fail "requirement '$($req.id)' satisfied_by references unknown object '$ref'"
137+
}
133138
}
134139
}
135140
}

0 commit comments

Comments
 (0)