Fork me on GitHub
#malli
<
2021-06-15
>
wcalderipe07:06:22

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 😅

Martín Varela07:06:24

[:string {:min 1}] is probably what you're after...

👍 8
ikitommi08:06:03

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.

ikitommi08:06:47

e.g. post-int? vs [:int {:min 1}]

wcalderipe11:06:15

@U95NTJT4H thanks for the suggestion – I knew there was a better way to solve that problem.

👍 2
Martín Varela11:06:12

Glad that helped 🙂

wcalderipe11:06:16

@U055NJ5CC got it. For custom keyword types, we would have to provide a registry, right?

wcalderipe11:06:34

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:

Vladislav19:06:50

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

ikitommi19:06:03

@UNJE65T24 It might be that the references should copied to top-level swagger. If you can provide a minimal repro, would help solving

ikitommi19:06:25

also, what version of swagger-ui are you using?

Vladislav20:06:23

@U055NJ5CC i use swagger-ui bundled with

[metosin/reitit-swagger-ui "0.5.13"]
[metosin/ring-swagger-ui "3.36.0"]
guess it 3.XX

Vladislav20:06:23

i'v got example of that malli

Vladislav20:06:09

if i malli.json-schema/transform this (it is used in swagger gen, right?) i get something like

Vladislav20:06:44

and it has no valuable

#/definitions/Expression
as you can see

Vladislav07:06:47

should i submit an issue to github?)