Introducing Malli, a new data validation and specification library for Clojure/Script

[metosin/malli "0.2.0"] is out. This version adds the following:

  • improved handling of schema references: conditional walking, generators, JSON and Swagger Schemas
  • BREAKING (MINOR): map-utilities in malli.util automatically deref the top-level schemas
  • optional schema transformation schemas: :merge, :union and :select-keys
  • new options for explicitly configuring or disabling sci
  • support microsecond precision when parsing datetime strings
  • OpenAPI 3.0.3 polymorphism example playable in malli.io (click Pet).
[:schema {:registry {"Pet" [:map
                            [:type string?]
                            [:name string?]]
                     "Cat" [:merge
                            "Pet"
                            [:map
                             [:type [:= "Cat"]]
                             [:huntingSkill [:enum {:description "The measured skill for hunting"}
                                             :clueless, :lazy, :adventurous, :aggressive]]]]
                     "Dog" [:merge
                            "Pet"
                            [:map
                             [:type [:= "Dog"]]
                             [:packSize [:int {:min 0,
                                               :default 0
                                               :description "the size of the pack the dog is from"}]]]]}}
 [:multi {:dispatch :type} "Cat" "Dog"]]

Latest metosin/reitit is also now compatible with the non-alpha malli.

See the full CHANGELOG for details.

2 Likes