m/parse
and m/parser
now in master. Feedback and test reports most welcome.
m/parse
looks great! I think that's going to clean up a lot of my code once I get a chance to use it
updated README with parsing examples: https://github.com/metosin/malli#parsing-values
:or
, :cat
and :alt
all use non-named branches, :or*
, :cat*
and :alt*
are the named variants.
if somenone has better names for those, please suggest.
the hiccup example is from minimallist, thanks to @vincent.cantin for the original example 🙂
I like it 🙂
Naming things is hard, indeed.
@ikitommi in Malli’s version, there is no indication that the :node
is a vector. Was it intentional?
Hi! I'm using malli for the first time on a project where I have to derive HTML-Forms from the body-structure of http-requests. So far the experience has been great – and much more natural than with spec.
Now I feel the need for something I was unable to find in the Readme. Say I have the following schema definition:
[:map {:closed true} [:a int? :b int?]]
I would like to further constrain :b
depending on :a
, e.g.:
- :b
must be greater than :a
— or —
- :b
should only be present iff :a
is greater than 3 (nil otherwise)
Is there a way to express this without recourse to [:fn ]
schemas?
I'll be thankful for any hints on this!
Oh, that is missing. It accepts all sequences
can't compose with :and
here, need to constraint in some other way
without the vector indication, the generator might create a list, that's a problem.
you can add :gen/fmap vec
to gen a vec, but having a :kind
etc. property would make it work in all the places (validate, gen, transform)
how would I annotate a function for runtime checking at dev time?
@emccue no such thing yet, but should be easy to add. contributions welcome. https://github.com/metosin/malli/issues/349
@services :and
& :fn
is the way to do it now.
Hi, sorry for taking so long to respond… many thanks for the playground example… I wasn't even aware that existed. I'll be using [:fn …] then. straightforward!