Skip to content

Commit 0f00764

Browse files
committed
fix: improve check data schema algorithm
1 parent e13cb35 commit 0f00764

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,46 @@ <h2>The <dfn>InteractionOutput</dfn> interface</h2>
10571057
<section><h3>The <dfn>check data schema</dfn> algorithm</h3>
10581058
To run the <a>check data schema</a> steps on |payload| and |schema:object|,
10591059
<ol>
1060+
<li>
1061+
If |schema| is `null` or `undefined`, return `undefined`.
1062+
</li>
1063+
<li>
1064+
<!--
1065+
TODO: Should we just continue with the rest of the algorithm here?
1066+
-->
1067+
If |schema|.|default| is not |undefined| and |payload| is undefined,
1068+
let |payload| be the value of |schema|.|default|.
1069+
</li>
1070+
<li>
1071+
Let |const| be |schema|.|const|.
1072+
If |const| is not |undefined|,
1073+
<ol>
1074+
<li>
1075+
<!-- TODO: Should we already return here? -->
1076+
If |const| equals |payload|, return |payload|.
1077+
</li>
1078+
<li>
1079+
If |const| does not equal |payload|, throw {{TypeError}} and stop.
1080+
</li>
1081+
</ol>
1082+
</li>
1083+
<li>
1084+
If |schema|.|enum| is not |undefined| and none of the elements in
1085+
|schema|.|enum| equal |payload|, throw {{TypeError}} and stop.
1086+
</li>
1087+
<li>
1088+
Let |oneOf| be |schema|.|oneOf|.
1089+
If |oneOf| is not |undefined|,
1090+
<ol>
1091+
<li>
1092+
For each |subSchema| in |oneOf|, run the <a>check data schema</a>
1093+
steps on |payload| and |subSchema|.
1094+
</li>
1095+
<li>
1096+
If all of these runs throw, throw {{TypeError}} and stop.
1097+
</li>
1098+
</ol>
1099+
</li>
10601100
<li>
10611101
Let |type| be |schema|.|type|.
10621102
</li>

0 commit comments

Comments
 (0)