Open ikitommi opened 1 year ago
The awesome Plumatic Schema has concept of Abstract Map:
Abstract Map
;; abstract-map (experimental) models "abstract classes" and "subclasses" with maps. (require '[schema.experimental.abstract-map :as abstract-map]) (s/defschema Animal (abstract-map/abstract-map-schema :type {:name s/Str})) (abstract-map/extend-schema Cat Animal [:cat] {:claws? s/Bool}) (abstract-map/extend-schema Dog Animal [:dog] {:barks? s/Bool}) (s/validate Cat {:type :cat :name "melvin" :claws? true}) (s/validate Animal {:type :cat :name "melvin" :claws? true}) (s/validate Animal {:type :dog :name "roofer" :barks? true}) (s/validate Animal {:type :cat :name "confused kitty" :barks? true}) ;; RuntimeException: ;; Value does not match schema: {:claws? missing-required-key, :barks? disallowed-key}
we could have that too.
The awesome Plumatic Schema has concept of
Abstract Map
:we could have that too.