-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
144 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,8 +194,7 @@ For example, consider the following `args` from an `Invocation`: | |
"cc": ["[email protected]"], | ||
"title": "Meeting Confirmation", | ||
"body": "I'll see you on Tuesday" | ||
}, | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
|
@@ -279,6 +278,7 @@ NOTE: You cannot add _any_ indentation to this table if you want | |
<td> | ||
|
||
``` json | ||
// FIXME double check with implementation | ||
null | ||
``` | ||
|
||
|
@@ -289,32 +289,159 @@ null | |
|
||
### Validation | ||
|
||
## Examples | ||
Validation | ||
|
||
``` js | ||
// Delegation | ||
{ | ||
"cmd": "/msg/send", | ||
"pol": [ | ||
["==", ".from", "[email protected]" | ||
["==", ".title", "Coffee"] | ||
], | ||
// ... | ||
} | ||
Being tree structured, evaluation MAY proceed in any order. Here is one step-by-step example: | ||
|
||
// Valid invocation | ||
{ | ||
<details> | ||
<summary>Example Context</summary> | ||
|
||
``` js | ||
{ // Invocation | ||
"cmd": "/msg/send", | ||
"args": { | ||
"from": "[email protected]", // Matches above | ||
"from": "[email protected]", | ||
"to": ["[email protected]", "[email protected]"], | ||
"title": "Coffee", | ||
"body": "Still on for coffee" // Matches above | ||
"body": "Still on for coffee" | ||
}, | ||
// ... | ||
} | ||
|
||
{ // Delegation | ||
"cmd": "/msg", | ||
"pol": [ | ||
["==", ".from", "[email protected]"], | ||
["some", ".to", ["match", ".", "*@example.com"]] | ||
], | ||
// ... | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>Code Example</summary> | ||
|
||
``` js | ||
// Extract policy | ||
[ | ||
["==", ".from", "[email protected]"], | ||
["some", ".to", ["match", ".", "*@example.com"]] | ||
] | ||
|
||
// Resolve selectors | ||
[ | ||
["==", "[email protected]", "[email protected]"], | ||
["some", ["[email protected]", "[email protected]"], ["match", ".", "*@example.com"]] | ||
] | ||
|
||
// Expand quantifier | ||
[ | ||
["==", "[email protected]", "[email protected]"], | ||
["or", [ | ||
["match", "[email protected]", "*@example.com"] | ||
["match", "[email protected]", "*@example.com"]]] | ||
] | ||
|
||
// Evaluate first clause | ||
[ | ||
true, | ||
["or", [ | ||
["match", "[email protected]", "*@example.com"] | ||
["match", "[email protected]", "*@example.com"]]] | ||
] | ||
|
||
// Evaluate second clause's children | ||
[ | ||
true, | ||
["or", [true, false]] | ||
] | ||
|
||
// Evaluate second clause | ||
[true, true] | ||
|
||
// Implicit top-level `and` | ||
true | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
|
||
<summary>Graphical Example</summary> | ||
|
||
``` mermaid | ||
flowchart BT | ||
policy | ||
eq["=="] --> policy | ||
from[".from"] --> eq | ||
alice["[email protected]"] --> eq | ||
some --> policy | ||
to[".to"] --> some | ||
match --> some | ||
this["."] --> match | ||
pattern["*@example.com"] --> match | ||
``` | ||
|
||
``` mermaid | ||
flowchart BT | ||
policy | ||
eq["=="] --> policy | ||
from["[email protected]"] --> eq | ||
alice["[email protected]"] --> eq | ||
some --> policy | ||
to["[]"] --> some | ||
bob["[email protected]"] --> to | ||
carol["[email protected]"] --> to | ||
match --> some | ||
this["."] --> match | ||
pattern["*@example.com"] --> match | ||
``` | ||
|
||
``` mermaid | ||
flowchart BT | ||
policy | ||
eq["=="] --> policy | ||
from["[email protected]"] --> eq | ||
alice["[email protected]"] --> eq | ||
or --> policy | ||
match_bob --> or | ||
bob["[email protected]"] --> match_bob | ||
bob_pattern["*@example.com"] --> match_bob | ||
match_carol --> or | ||
carol["[email protected]"] --> match_carol | ||
carol_pattern["*@example.com"] --> match_carol | ||
``` | ||
|
||
``` mermaid | ||
flowchart BT | ||
policy | ||
alice["true"] --> policy | ||
or --> policy | ||
match_bob["true"] --> or | ||
match_carol["false"] --> or | ||
``` | ||
|
||
``` mermaid | ||
flowchart BT | ||
policy | ||
alice["true"] --> policy | ||
or["true"] --> policy | ||
``` | ||
|
||
``` mermaid | ||
flowchart BT | ||
true | ||
``` | ||
|
||
</details> | ||
|
||
Any arguments MUST be taken verbatim and MUST NOT be further adjusted. For more flexible validation of Arguments, use [Conditions]. | ||
|
||
Note that this also applies to arrays and objects. For example, the `to` array in this example is considered to be exact, so the Invocation fails validation in this case: | ||
|