Skip to content

Commit

Permalink
fix: improve check data schema algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Feb 12, 2024
1 parent e13cb35 commit 8bda034
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,46 @@ <h2>The <dfn>InteractionOutput</dfn> interface</h2>
<section><h3>The <dfn>check data schema</dfn> algorithm</h3>
To run the <a>check data schema</a> steps on |payload| and |schema:object|,
<ol>
<li>
If |schema| is `null` or `undefined`, return `undefined`.
</li>
<li>
<!--
TODO: Should we just continue with the rest of the algorithm here?
-->
If |schema|.|default| is not |undefined| and |payload| is undefined,
let |payload| be the value of |schema|.|default|.
</li>
<li>
Let |const| be |schema|.|const|.
If |const| is not |undefined|,
<ol>
<li>
<!-- TODO: Should we already return here? -->
If |const| equals |payload|, return |payload|.
</li>
<li>
If |const| does not equal |payload|, throw {{TypeError}} and stop.
</li>
</ol>
</li>
<li>
If |schema|.|enum| is not |undefined| and none of the elements in
|schema|.|enum| equal value, throw {{TypeError}} and stop.
</li>
<li>
Let |oneOf| be |schema|.|oneOf|.
If |oneOf| is not |undefined|,
<ol>
<li>
For each |subSchema| in |oneOf|, run the <a>check data schema</a>
steps on |payload| and |subSchema|.
</li>
<li>
If all of these runs throw, throw {{TypeError}} and stop.
</li>
</ol>
</li>
<li>
Let |type| be |schema|.|type|.
</li>
Expand Down

0 comments on commit 8bda034

Please sign in to comment.