After a year in incubation, we are proud to present Malli , a new data validation and specification library for Clojure/Script! Big thanks to Clojurists Together for helping to ship it out.
Introduction post: https://www.metosin.fi/blog/malli/
In short, Malli covers:
schema definitions, as data
support for open and closed maps
data validation and error reporting
humanised and localised error messages
spell-checking of map and multi keys
bi-directional value transformation
value and schema generation
tools for programming with schemas
immutable, mutable, dynamic, lazy and composite registries
support for JSON Schema, Swagger and DOT
open apis for both end users and extenders
Coordinates:
On behalf of Metosin and all contributors,
Tommi
20 Likes
Looking great, just a few questions:
Can Malli spec functions and macros as well? Or just data?
Also, is there any support for data generation and generative testing?
Just data now. But all of sequence schemas , schema parsing and function schemas are WIP.
Data generation works, leans on test.check , no special utilities for generative testing currently.
Some screenshots of things to come:
6 Likes
Been waiting for Malli to come out publically for a while now. It looks great!
I like that the project promises a migration path if ever it would be needed
[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
system
Closed
April 19, 2021, 6:08pm
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.