(check x)Validates that all references in data structure x have unique referents.
Throws :invalid/reference if the same referent appears with different specifications (e.g., :ref/id and :ref?/id, or :ref#int/x and :ref#string/x).
Returns x unchanged if validation passes.
Example: (check {:path [:ref/id] :query {:name :ref?/name}}) ;; => {:path [:ref/id] :query {:name :ref?/name}}
(check {:path [:ref/id] :query {:id :ref?/id}}) ;; => throws ExceptionInfo
Validates that all references in data structure x have unique referents.
Throws :invalid/reference if the same referent appears with different
specifications (e.g., :ref/id and :ref?/id, or :ref#int/x and :ref#string/x).
Returns x unchanged if validation passes.
Example:
(check {:path [:ref/id] :query {:name :ref?/name}})
;; => {:path [:ref/id] :query {:name :ref?/name}}
(check {:path [:ref/id] :query {:id :ref?/id}})
;; => throws ExceptionInfo(extract x)Recursively traverses the given data structure x and collects all unique
reference keywords (e.g., :ref/variable or :ref?/variable).
Returns a set containing all the encountered reference keywords intact, preserving their original namespaces so they can be classified later.
Example: (extract {:path [:room :ref/id] :request {:name :ref?/name}}) ;; => #{:ref/id :ref?/name}
Recursively traverses the given data structure `x` and collects all unique
reference keywords (e.g., :ref/variable or :ref?/variable).
Returns a set containing all the encountered reference keywords intact,
preserving their original namespaces so they can be classified later.
Example:
(extract {:path [:room :ref/id] :request {:name :ref?/name}})
;; => #{:ref/id :ref?/name}(optional-reference? x)Returns true if x is an optional reference keyword (e.g., :ref?/filter, :ref?#string/term). Otherwise, returns false.
Returns true if x is an optional reference keyword (e.g., :ref?/filter, :ref?#string/term). Otherwise, returns false.
(parse k)Parses a reference keyword into a map with :kind (:required or :optional), :referent (keyword), and optionally :type (keyword). Returns nil if k is not a valid reference.
Parses a reference keyword into a map with :kind (:required or :optional), :referent (keyword), and optionally :type (keyword). Returns nil if k is not a valid reference.
(reference? x)Returns true if x is a reference keyword (e.g., :ref/id, :ref?/opt, :ref#int/num). Returns false otherwise.
Returns true if x is a reference keyword (e.g., :ref/id, :ref?/opt, :ref#int/num). Returns false otherwise.
(referent ref)Returns the underlying target keyword (the referent) of a given reference by stripping away its 'ref' or 'ref?' namespace.
Example: (referent :ref/patientId) ;; => :patientId (referent :ref?/patientId) ;; => :patientId (referent :plain-keyword) ;; => nil
Returns the underlying target keyword (the referent) of a given reference by stripping away its 'ref' or 'ref?' namespace. Example: (referent :ref/patientId) ;; => :patientId (referent :ref?/patientId) ;; => :patientId (referent :plain-keyword) ;; => nil
(required-reference? x)Returns true if x is a required reference keyword (e.g., :ref/patientId, :ref#int/limit). Otherwise, returns false.
Returns true if x is a required reference keyword (e.g., :ref/patientId, :ref#int/limit). Otherwise, returns false.
(resolve ref-bindings x)Recursively traverses the given form (maps, vectors, lists, etc.)
and replaces any placeholder keyword matching the format :ref/variable-name
with its corresponding runtime value extracted from ref-bindings.
Arguments:
ref-bindings: A map containing runtime dynamic data (e.g., {:patientId "123"}).form: Any Clojure data structure or template that contains :ref/... keywords.Returns: The deeply transformed data structure with all references resolved.
Throws:
clojure.lang.ExceptionInfo if a required :ref/... keyword found in the form
cannot be resolved within the provided ref-bindings map. The exception
includes the full original context for deep production debugging.
Recursively traverses the given `form` (maps, vectors, lists, etc.)
and replaces any placeholder keyword matching the format :ref/variable-name
with its corresponding runtime value extracted from `ref-bindings`.
Arguments:
- `ref-bindings`: A map containing runtime dynamic data (e.g., {:patientId "123"}).
- `form`: Any Clojure data structure or template that contains :ref/... keywords.
Returns:
The deeply transformed data structure with all references resolved.
Throws:
clojure.lang.ExceptionInfo if a required :ref/... keyword found in the form
cannot be resolved within the provided `ref-bindings` map. The exception
includes the full original context for deep production debugging.(validate-ref-bindings ref-bindings)Returns true when ref-bindings is a Clojure map, else throws :invalid/type error
Returns true when ref-bindings is a Clojure map, else throws :invalid/type error
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |