Skip to content

Commit

Permalink
match -> like
Browse files Browse the repository at this point in the history
  • Loading branch information
expede committed Aug 5, 2024
1 parent 46b20a7 commit 0c6bd01
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Here is an illustrative example:
"cmd": "/blog/post/create",
"pol": [
["==", ".status", "draft"],
["every", ".reviewer", ["match", ".email", "*@example.com"]],
["every", ".reviewer", ["like", ".email", "*@example.com"]],
["some", ".tags",
["or",
["==", ".", "news"],
Expand Down Expand Up @@ -136,7 +136,7 @@ Below is a formal syntax for the UCAN Policy Language given in [ABNF] (for DAG-J
policy = "[" *1(statement *("," statement)) "]"
statement = equality
/ inequality
/ match
/ like
/ connective
/ quantifier
Expand All @@ -157,7 +157,7 @@ inequality = "[" DQUOTE ">" DQUOTE "," selector "," number "]" ; Numeric great
/ "[" DQUOTE "<" DQUOTE "," selector "," number "]" ; Numeric lesser-than
/ "[" DQUOTE "<=" DQUOTE "," selector "," number "]" ; Numeric lesser-than-or-equal
match = "[" DQUOTE "match" DQUOTE "," selector "," pattern "]" ; String wildcard matching
like = "[" DQUOTE "like" DQUOTE "," selector "," pattern "]" ; String wildcard matching
;; SELECTORS
Expand Down Expand Up @@ -191,9 +191,9 @@ Numeric inequalities MUST be agnostic to numeric type. In other words, the decim

## Glob Matching

| Operator | Argument(s) | Example |
|----------|---------------------|-------------------------------------|
| `match` | `Selector, Pattern` | `["==", ".email", "*@example.com"]` |
| Operator | Argument(s) | Example |
|----------|---------------------|---------------------------------------|
| `like` | `Selector, Pattern` | `["like", ".email", "*@example.com"]` |

Glob patterns MUST only include one specicial character: `*` ("wildcard"). There is no single character matcher. As many `*`s as desired MAY be used. Non-wildcard `*`-literals MUST be escaped (`"\*"`). Attempting to match on a non-string MUST return false and MUST NOT throw an exception.

Expand Down Expand Up @@ -455,7 +455,7 @@ Below is a step-by-step evaluation example:
"cmd": "/msg",
"pol": [
["==", ".from", "[email protected]"],
["some", ".to", ["match", ".", "*@example.com"]]
["some", ".to", ["like", ".", "*@example.com"]]
],
// ...
}
Expand All @@ -464,27 +464,27 @@ Below is a step-by-step evaluation example:
``` js
[ // Extract policy
["==", ".from", "[email protected]"],
["some", ".to", ["match", ".", "*@example.com"]]
["some", ".to", ["like", ".", "*@example.com"]]
]

[ // Resolve selectors
["==", "[email protected]", "[email protected]"],
["some", ["[email protected]", "[email protected]"], ["match", ".", "*@example.com"]]
["some", ["[email protected]", "[email protected]"], ["like", ".", "*@example.com"]]
]

[ // Expand quantifier
["==", "[email protected]", "[email protected]"],
["or", [
["match", "[email protected]", "*@example.com"]
["match", "[email protected]", "*@example.com"]]
["like", "[email protected]", "*@example.com"]
["like", "[email protected]", "*@example.com"]]
]
]

[ // Evaluate first predicate
true,
["or", [
["match", "[email protected]", "*@example.com"]
["match", "[email protected]", "*@example.com"]]]
["like", "[email protected]", "*@example.com"]
["like", "[email protected]", "*@example.com"]]]
]

[ // Evaluate second predicate's children
Expand Down Expand Up @@ -512,7 +512,7 @@ Note that this also applies to arrays and objects. For example, the `to` array i
"cmd": "/email/send",
"pol": [
["==", ".from", "[email protected]"],
["some", ".to", ["match", ".", "*@example.com"]]
["some", ".to", ["like", ".", "*@example.com"]]
]
// ...
}
Expand Down

0 comments on commit 0c6bd01

Please sign in to comment.