malli
malli copied to clipboard
WIP: Generalize properties to constraints
Merge first: https://github.com/metosin/malli/pull/1029
In prototyping phase. Overall goal is to obviate the need for :and
, :not
, and :fn
schemas, in particular because of their brittle generators. It also leads more more relevant error messages https://github.com/metosin/malli/issues/1001.
TODO
- [x] validate
- [x] explain
- [x] generate
- [ ] transform
- [x] parse
- [ ] merge/union
Ideas:
- [x] (Noah) allow
:or
property[:map {:or [:a :b :c]} ..]
- [x] rename
:keys
to:keyset
- [x] enhance
:set
with the same properties for heterogeneous sets - [x] enhance
:map-of
with keyset constraints - [x] generalize beyond keysets, just call them "constraints".
- [x] rename
:keyset
to:and
. - [x] integer constraints
[:int {:> 5 :< 10}]
, easier to generate than[:and :int [:> 5] [:< 10]]
. - [x] make
:min
:max
constraints so they can participate in constraint resolution - [x] extend to
:double
- [x] take
:gen/min
:gen/max
into account earlier during solution generation - [x] perhaps
:gen/and
:gen/or
etc? - [x]
:string
constraints - [x] extend humanize output to structure logical operators explicitly ("should either a or b" => [:or "should a" "should b"])
- [x]
:dispatch
constraint
[:multi {:dispatch :db/valueType}
[:db.type/tuple [:map {:xor [:db/tupleType :db/tupleAttrs :db/tupleTypes]}
[:db/tupleType {:optional true} ...]
[:db/tupleAttrs {:optional true} ...]
[:db/tupleTypes {:optional true} ...]]]]
==>
[:map {:dispatch [:db/valueType
[:db.type/tuple [:xor :db/tupleType :db/tupleAttrs :db/tupleTypes]]]
[:db.type/string ...]
[:db.type/ref ...]}
[:db/tupleType {:optional true} ...]
[:db/tupleAttrs {:optional true} ...]
[:db/tupleTypes {:optional true} ...]]