schema

svt 2020-09-14T11:52:38.002400Z

(def Foo (schema/if (fn [data] (= "someType" (:type data)))
                {:firstName        schema/Str
                 :lastName         (schema/pred helper/valid?)
                 :company          (schema/pred helper/valid?)
                 :gender           (schema/pred helper/valid-gender?)
                 :type     (schema/pred helper/valid-foo-type?)}
                {:firstName                     schema/Str
                 :lastName                      (schema/pred helper/valid?)
                 (schema/optional-key :company) schema/Str
                 :gender                        (schema/pred helper/valid-gender?)
                 :type                  (schema/pred helper/valid-foo-type?)}))
I’m using this kind of schema to validate something in my code. There is almost duplicate code with just one different key. Is there any better way to define it??