The simple wrapper for the malli library. Easy markup your secrets in one place - directly in your model.
The simple wrapper for the malli library. Easy markup your secrets in one place - directly in your model.
(transformer)
(transformer {:keys [key secrets] :or {key :secret.keeper/category secrets {}}})
Secret transformer.
Strategy:
Usage:
;; 1. Define your transformer
(def Transformer
(transformer
{:key :category ;; by default ::keeper/secret
:secrets {:passport :confidential
:password :internal-only}}))
;; 2. Define your schema
(def User
[:map
[:firstname string?]
[:lastname string?]
[:email string?]
[:passport string?]
[:address [:map {:category :personal}
[:street string?]
[:zip int?]
[:city string?]
[:country [:enum "Russia" "USA"]]]]
[:credentials [:map
[:login string?]
[:password string?]]]])
;; 3. Mark all secrets using the specified categories
(m/encode User <your-data> Transformer)
;; 4. Decode all secrets
(m/decode User <your-data> Transformer)
Secret transformer. - Encoder - encodes all secrets using the specified categories. - Decoder - decodes all secrets. Strategy: 1. Try to extract the category from the schema properties using the specified key. Important: The local category has the highest priority. 2. Try to extract the category from the transformer secrets map by the schema type 3. Otherwise, if the schema has any entries, we take the specified categories from the transformer secrets map by the entry key Usage: ``` ;; 1. Define your transformer (def Transformer (transformer {:key :category ;; by default ::keeper/secret :secrets {:passport :confidential :password :internal-only}})) ;; 2. Define your schema (def User [:map [:firstname string?] [:lastname string?] [:email string?] [:passport string?] [:address [:map {:category :personal} [:street string?] [:zip int?] [:city string?] [:country [:enum "Russia" "USA"]]]] [:credentials [:map [:login string?] [:password string?]]]]) ;; 3. Mark all secrets using the specified categories (m/encode User <your-data> Transformer) ;; 4. Decode all secrets (m/decode User <your-data> Transformer)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close