Fork me on GitHub
#malli
<
2022-10-27
>
souenzzo17:10:20

does malli has something like spec's conform operation? my use case is: my schema has an or

:a string?
:b int?
:ab [:or :a :b]
And I a function that given the :ab schema + a value, it tells me if the value is :a, :b or :invalid

ikitommi17:10:26

try m/parse & m/unparse. If you want named nodes, you can: [:orn [:s :string] [:b :boolean]]

ikitommi17:10:23

same with regexs, adding a n to the name, you can present the nodes in entry-style and get named results, e.g. :cat -> :catn, :alt -> :altn

mauricio.szabo21:10:02

Folks, can I ask for a huge improvement on Malli? Show the errors on instrument, on .pretty/explain, etc, at the end of everything

mauricio.szabo21:10:46

Sometimes when I get an error, I can't find it anywhere - either it is greater than my terminal buffer or it gets lost in the middle of a "your state is this" and "your schema is this"

mauricio.szabo21:10:10

It's not just inconvenient - on React-Native, for example, sometimes the console is not redirected to the REPL (because metro and other issues) so I keep having to disable and re-enable instrumentation 😢

dvingo14:10:38

the reporter option can be passed in to instrument and to start, so pretty quick work to copy the pretty namespace to your project and mess around how you like

mauricio.szabo15:10:00

I... actually have no idea what you mean 😄

mauricio.szabo15:10:06

Do you have an example?

dvingo18:10:57

(malli.dev/start! {:report (fn [type data] (.error js/console "Instrument error: " (str type)))})

mauricio.szabo18:10:26

Thanks, I'll try 🙂

mauricio.szabo23:10:32

Ok, for .pretty/explain there is a work-around - I can capture the :errors property and pretty-print them