Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(InteractionOutput): don't require schema.type in value function #534

Merged
merged 7 commits into from
Mar 4, 2024
28 changes: 26 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,8 @@ <h2>The <dfn>InteractionOutput</dfn> interface</h2>
</li>
<li>
If |this|.|data| is not a {{ReadableStream}} or if
|dataUsed| is `true`, or if |form| is not an {{object}} or if |schema| or its
|type| are `null` or `undefined`, then
|dataUsed| is `true`, or if |form| is not an {{object}} or if |schema|
is `null` or `undefined`, then
Comment on lines +979 to +980
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, this is (more or less) the change proposed by @relu91 in #534 (review). The question here, also raised by him, is how we should ensure that the schema is valid – do we need to define a separate algorithm for that?

Suggested change
|dataUsed| is `true`, or if |form| is not an {{object}} or if |schema|
is `null` or `undefined`, then
|dataUsed| is `true`, or if |form| is not an {{object}} or if |schema|
is `null` or `undefined` or not a valid schema, then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: JSON schema is VERY loose when it comes to what is a valid schema.. almost anything is a valid JSON schema. Hence I am not sure if it makes sense to do anything on top...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, I now remember that we also discussed this briefly on Friday during the Thingweb meeting... Then I suppose we should keep this step as is, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"not a valid schema" needs an algorithm

[=reject=] |promise| with {{NotReadableError}} and stop.
</li>
<li>
Expand Down Expand Up @@ -1057,6 +1057,30 @@ <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>
If |schema|.|const| is not |undefined| and |schema|.|const| does not equal |payload|, throw {{TypeError}} and stop.
</li>
<li>
If |schema|.|enum| is not |undefined| and none of the elements in
|schema|.|enum| equal |payload|, 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 none or more than one of these runs do not throw, throw
{{TypeError}} and stop.
</li>
</ol>
</li>
<li>
Let |type| be |schema|.|type|.
</li>
Expand Down