malli

https://github.com/metosin/malli :malli:
ikitommi 2021-06-15T04:45:45.134100Z

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]]]]

wcalderipe 2021-06-15T07:07:22.139800Z

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 πŸ˜…

2021-06-15T07:49:24.140Z

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

πŸ‘ 3
ikitommi 2021-06-15T08:29:03.140300Z

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.

ikitommi 2021-06-15T08:29:47.140500Z

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

wcalderipe 2021-06-15T11:46:15.143400Z

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

πŸ‘ 1
2021-06-15T11:47:12.143700Z

Glad that helped πŸ™‚

wcalderipe 2021-06-15T11:47:16.143900Z

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

wcalderipe 2021-06-15T11:51:34.144100Z

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:

wcalderipe 2021-06-15T17:04:49.144500Z

Got it.. thanks @ikitommi

Vladislav 2021-06-15T19:20:50.144900Z

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

Vladislav 2021-06-16T07:00:47.146900Z

should i submit an issue to github?)

ikitommi 2021-06-16T07:05:05.147100Z

please do

Vladislav 2021-06-16T07:11:43.147300Z

voila https://github.com/metosin/malli/issues/464

ikitommi 2021-06-15T19:43:03.145200Z

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

ikitommi 2021-06-15T19:43:25.145400Z

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

Vladislav 2021-06-15T20:47:23.145600Z

@ikitommi i use swagger-ui bundled with

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

Vladislav 2021-06-15T20:49:23.145800Z

i'v got example of that malli

Vladislav 2021-06-15T20:54:09.146200Z

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

Vladislav 2021-06-15T20:54:44.146600Z

and it has no valuable

#/definitions/Expression
as you can see