You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+51-1
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ Finally, if the condition is a type guard, the parameter you pass will be inferr
89
89
To define policies, you create a policy set using the `definePolicies` function.
90
90
Each policy definition is created using the `definePolicy` function, which takes a policy name and a callback that defines the policy logic (or a boolean value).
91
91
92
-
> [!IMPORTANT]
92
+
> [!IMPORTANT]
93
93
> For convenience, the condition can be a boolean value but **you will lose type inference**
94
94
>
95
95
> If you want TS to infer something (not null, union, etc), use a condition function
@@ -393,6 +393,56 @@ if (check(guard.post.policy("post has comments"), post)) {
393
393
console.log("Post has comments");
394
394
}
395
395
```
396
+
397
+
### `checkAllSettle`
398
+
Evaluates all the policies with `check` and returns a snapshot with the results.
399
+
400
+
It's useful to serialize policies.
401
+
402
+
```ts
403
+
export function checkAllSettle<TPolicies extends PolicyTuple[], TPolicyName extends TPolicies[number][0]["name"]>(
404
+
policies: TPolicies
405
+
): PoliciesSnapshot<TPolicyName>
406
+
```
407
+
408
+
Example:
409
+
```ts
410
+
// TLDR
411
+
constsnapshot=checkAllSettle([
412
+
[guard.post.policy("my post"), post],
413
+
[guard.post.policy("all my published posts"), post],
0 commit comments