Fork me on GitHub
#malli
<
2022-10-20
>
ikitommi06:10:48

try to answer both here: • if you you a regex schema inside a regex schema, it get’s inlined, so you can create a “flat” list using those • non-regex schemas just take one slot in the regex schema, so: ◦ [:orn [:s :string] [:bs [:+ :boolean]] is “a string or 1+ booleans” taking 1 slot ◦ [:altn [:s :string] [:bs [:+ :boolean]] is the same but if used inside a regex schema, the :+ get’s inlined ◦ you can’t inline a :ref in the regex schema ◦ wrapping any schema into :schema makes it “normal schema” and thus, it takes just one slot in the regex (`:ref` and regex schemas)

👍 1
😎 1
thanks3 1
timothypratley20:10:49

I see, thank you 🙂

skynet20:10:04

when I'm using malli in a terminal like setting, I kind of want the pretty explain output reversed from how it is seen on a webpage: https://github.com/valyagolev/malli/blob/c7c22a8fefd3a8491a35e1e320ab620791c4500c/src/malli/dev/pretty.cljc#L37-L40 since the bottom is closest to what I'm looking at, and the top stuff I might have to scroll up to see. luckily I'm able to call this whole defmethod myself, but maybe it's common enough that other people would find it useful to have a function in that namespace to set explain to "console" mode?

ikitommi06:10:24

console-mode sound good. Also, color themes (none/light/dark/custom) + html-emitting mode (for react error boundaries etc). How different would the :console mode be from the normal? All mm-methods should be different? just the one? some amount of config can be done via adding configuration options to the printer (it’s backed by a map), but if it’s totally different (the html-mode could be), then another mm & ns might be better.

skynet13:10:36

I'm currently just rearranging the blocks (and removing the "more info" block):

(defmethod v/-format ::m/explain
  ...
    (-block "Schema:"
    (-block "Value:"
    (-block "Errors:"
only other thing I might change is the amount of whitespace. there's like 3 blank lines after the error, I might reduce to 1 line. mayyybe remove blank lines after the Schema:, Value:, Errors: section titles and content, but that could make it less readable

ikitommi06:10:24

console-mode sound good. Also, color themes (none/light/dark/custom) + html-emitting mode (for react error boundaries etc). How different would the :console mode be from the normal? All mm-methods should be different? just the one? some amount of config can be done via adding configuration options to the printer (it’s backed by a map), but if it’s totally different (the html-mode could be), then another mm & ns might be better.