schema

RAJKUMAR 2024-09-02T23:28:20.304689Z

Hi I need help related to schema

RAJKUMAR 2024-09-02T23:28:31.866129Z

below is the code

RAJKUMAR 2024-09-02T23:28:36.533849Z

(require '[schema-tools.core :as st])
(require '[schema.coerce :as sc])
(require '[schema.core :as s])

(def input-map {:a "a" :b 2})

(schema.core/defschema input-schema 
  (linked.core/map 
    (s/optional-key :c) schema.core/Str))

(st/select-schema input-map input-schema sc/json-coercion-matcher)

RAJKUMAR 2024-09-02T23:29:29.863169Z

I want select schema to return empty map {} when the input-map is not nil

RAJKUMAR 2024-09-02T23:29:42.053659Z

when it is nil it can return nil

RAJKUMAR 2024-09-02T23:29:59.221159Z

how can I define the input-schema for that?