Fork me on GitHub
Michaël Salihi09:05:53

Hi! Is Malli a good candidate to use for server side form validation in replacement for lib like Especially thanks to malli.error / humanize?

Michaël Salihi09:05:35

With some hand made regex validators (email, etc) like + locale support, I think so, right?

Michaël Salihi09:05:28

Perfect, thanks for the confirmation. I'll toy with Malli in a project and see how to organize this. 👍

Michaël Salihi09:05:42

is there an example demo project with form validation somewhere?

Michaël Salihi09:05:01

I like very much the Reitit's example folder, if my tests are successful after a code review, I may be able to contribute with an example PR with form validation on Malli's Github.

Michaël Salihi09:05:41

What do you think?


sure, examples welcome! I have a malli-form (reagent) demo draft, but nothing serious.

Michaël Salihi10:05:15

Perfect, let's do this!


has form validation


you're most welcome

👍 5

hi, Anyone know if Malli has support that allows you to set a default value if the value doesn't pass the schema check?


You mean this?


looks like that just sets a default if the value is missing:

 [:and {:default 42} int?]
 "test");; => :malli.core/invalid

(m/decode [:and {:default 42} int?]
          mt/default-value-transformer);; => "test"
I'll probably just use m/explain and do something based on if there are errors


might not be simple as any fix could change the conditional branch that should be used (with :or and :multi). But you should be able to use malli.util functions to access the invalid paths and work from there.

👍 2

possibly. Generally I just want to check a map is valid but keep any good values and log out any errors


hi! Deref of [:merge ...] makes :registry with nested schemas of one of merged schemas invisible (but it still works). is it a bug, or feature, or there is some workaround Im missing? point is - registry disappears from any of serialisations after deref, although it contains all information about recursive fields, and i assume there is no other way of define recursive schemas. of course, i still could use underefed schema, but it much complicated


Can't recall where it was discussed, but we should clearly separate the locally registered schemas from normal registered ones and with the malli.util fns, expose the accumulated local registry, to be used in schema form. This makes the schemas visible and thus, serializable.


small change, clears thing a lot.


I tried to find some way of extract and then serialize registry from schema (`m/-registry`, and then malli.registry/schemas ), but sadly unsuccess - it still needs more class serialization (may be to deref every schema from it? - leave it for tomorrow)