Fork me on GitHub
#malli
<
2022-08-15
>
pinkfrog10:08:12

Hi, running this example I got sci not available

(m/decode
  [string? {:decode/string 'str/upper-case}]
  "kerran" mt/string-transformer)
; Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:138). ; :malli.core/sci-not-available {:code str/upper-case}

borkdude10:08:00

I think you should include SCI as an optional dependency yourself. If you don't use the quotes, you won't need SCI

☝️ 1
pinkfrog10:08:03

Thanks. Dunno what’s the added benefits of sci.

borkdude10:08:10

The benefit of SCI would be if you would like to serialize your schemas to the front-end

borkdude10:08:18

The quote is only needed for serialization

pinkfrog10:08:31

Then why not a custom export function to convert function to its symbol names. I am not quite getting the actual benefits compared of importing sci here.

borkdude10:08:31

Because just a symbol won't give you evaluation in the client

pinkfrog10:08:30

When client are you referring to the js environment? Also, pardon me, are we assuming sci could run on js (given the recent work of nbb and such)

borkdude10:08:49

yes, JavaScript

borkdude10:08:29

you can include malli on the client side and then use SCI to evaluate your schemas and get exactly the same validation as on the server

thanks3 1
borkdude10:08:01

So you can send your schema's dynamically to the client

pinkfrog10:08:46

> So you can send your schema’s dynamically to the client That is so futuristic, that I am not sure I am ready.

valtteri11:08:31

In the latest version of the README the examples have been changed to not require SCI unless mentioned.

👍 1
valtteri11:08:08

I think this particular one is now

(m/decode
  [string? {:decode/string clojure.string/upper-case}]
  "kerran" mt/string-transformer)
; => "KERRAN"

pinkfrog10:08:26

I wonder why https://cljdoc.org/d/metosin/malli/0.8.9/doc/readme#value-transformation:~:text=Adding%20optional%20keys%20too%20via%20%3A%3Amt/add%2Doptional%2Dkeys%20option%3A. here uses qualified keyword, ::mt/add-optional-keys, but others like :decode/encode does not use qualfied ones

ikitommi12:08:46

Malli started with simple keywords everywhere, but as the options are passed everywhere, this doesn’t scale well -> moved to use qualified keywords. Could clean up all options for 1.0.0?

ikitommi12:08:23

One ideas was to have default global options map, could be read from EDN-file, set like the registry etc and which could be tune all different parts of the system. Not there yet.

pinkfrog13:08:15

I’d like to learn more on the scale well part. When I am writing something only used internally, I will use qualified keywords, because this helps jump to usage, bulk rename, etc. But when I am providing some opts map for the user, I will use simple keyword. Mandating qualified keywords kinda complicates the opts map.

ikitommi15:08:31

Malli options has :`registry` being the only reserved simple key. There are some qualified keys used in core like ::m/walk-entry-vals, which are relevant only in a special use case (here, using m/walk). If we had two option arguments ("how the system is configured" and "how this use case should work") we could use simple keys in both. Now, it's just one arg, and I think it's better to namespace the latter keys to avoid conflicts and to document which ns owns them. You can merge 'em all into one map and pass it everywhere.

thanks3 1
ikitommi15:08:11

I recall there are two open issues related to how to manage the global options better. Both would introduce a breaking change in the public APIs.

ikitommi15:08:08

I would like to remove the "pass in optional options arg to every function", have ideas on that, but, need to think about it first.