yeah. :multi
is not currntly mergable, oftenly asked. would allow concise definitions like:
[:merge
[:map [:id :uuid]]
[:multi {:dispatch :type}
[:pear [:size :int]]
[:boat [:price :int]]]]
Hey folks π
Why explain
keeps passing values forward when previous operations in an and
condition have already failed?
(m/explain
[:map
[:name
[:and string?
[:not {:error/message "non empty string"} empty?]]]]
{:name 1})
The example above throws Don't know how to create ISeq from: java.lang.Long
. It does at (empty? 1)
. The conditions are concatenated with an and
operator, so I wasn't expecting [:not {:error/message "non empty string"} empty?]
to run because string?
failed in the first place.
Note: there are probably better ways to express a non-empty string with Malli π
[:string {:min 1}]
is probably what you're after...
yes, I think itβs better to have keyword types (e.g. :string
) with properties than to use the existing core functions, of which, many throw on invalid input.
e.g. post-int?
vs [:int {:min 1}]
@martin887 thanks for the suggestion β I knew there was a better way to solve that problem.
Glad that helped π
@ikitommi got it. For custom keyword types, we would have to provide a registry, right?
So, I assume Malli will check the value against every keyword type of a field, even when using an AND operator and the first check fails, in order to get a complete errors map in the first run :thinking_face:
Got it.. thanks @ikitommi
Hi! I try to use malli as coercion&schemas with swagger ui. If i try serialise recursive schemas with registries, i get some "Could not resolve reference" of keys of recursive values. it is according to plan and swagger bad, or its just undone feature?) looks like there is some missing defs in swagger.json
should i submit an issue to github?)
please do
@shishkov61 It might be that the references should copied to top-level swagger. If you can provide a minimal repro, would help solving
also, what version of swagger-ui are you using?
@ikitommi i use swagger-ui bundled with
[metosin/reitit-swagger-ui "0.5.13"]
[metosin/ring-swagger-ui "3.36.0"]
guess it 3.XXi'v got example of that malli
if i malli.json-schema/transform
this (it is used in swagger gen, right?) i get something like
and it has no valuable
#/definitions/Expression
as you can see