Skip to main content
Last updated

Keysets

define-keyset

name string keyset string  string

name string  string

Define keyset as NAME with KEYSET, or if unspecified, read NAME from message payload as keyset, similarly to 'read-keyset'. If keyset NAME already exists, keyset will be enforced before updating to new value.

pact
(define-keyset 'admin-keyset (read-keyset "keyset"))
pact
(define-keyset 'admin-keyset (read-keyset "keyset"))

Top level only: this function will fail if used in module code.

enforce-keyset

guard guard  bool

keysetname string  bool

Execute GUARD, or defined keyset KEYSETNAME, to enforce desired predicate logic.

pact
(enforce-keyset 'admin-keyset)(enforce-keyset row-guard)
pact
(enforce-keyset 'admin-keyset)(enforce-keyset row-guard)

keys-2

count integer matched integer  bool

Keyset predicate function to match at least 2 keys in keyset.

pact
pact> (keys-2 3 1)false
pact
pact> (keys-2 3 1)false

keys-all

count integer matched integer  bool

Keyset predicate function to match all keys in keyset.

pact
pact> (keys-all 3 3)true
pact
pact> (keys-all 3 3)true

keys-any

count integer matched integer  bool

Keyset predicate function to match any (at least 1) key in keyset.

pact
pact> (keys-any 10 1)true
pact
pact> (keys-any 10 1)true

read-keyset

key string  keyset

Read KEY from message data body as keyset ({ "keys": KEYLIST, "pred": PREDFUN }). PREDFUN should resolve to a keys predicate.

pact
(read-keyset "admin-keyset")
pact
(read-keyset "admin-keyset")