I think a breaking change for the 1.0 release is ok. We know you plan to accrete only from 1.0
optional sci is great for the browser use case. making that the default is a good idea imho
I’m gonna use it server side also
@love.lagerkvist I'm using re-frame.core/reg-global-interceptor
to verify the app-db matches my schema in every change, and prints an console warning if it doesn't conform. But re-frame.app-db is just a normal map (live inside an reagent.atom), so it's nothing special when using it with malli IMO.
good reason not yet to read sci-powered schemas from untrusted sources: https://github.com/borkdude/sci/issues/348
that's now linked in Malli Readme.
@ikitommi note that termination safe does have impact on performance of realizing seqs (since it’s checked). I’m not sure if the issue about execution time is fundamentally solvable.
@wxitb2017 that sounds about right, I’ll do that. However, I was also thinking if it was possible to co-locate/generate/properly infer an inital app-db directly from malli. It would be really nice to have a single source of truth, kind of like a reitit router with views, coercion and controllers. (it’s probably super possible and I have to dig more into malli or a very bad idea)
It is one of the harder problems in comp.sci ;) With Malli & sci, I concider safety as more important. Following the issue & pr on sci-side, happy to incorporate anything that is found for this.
I think the fundamental solution would be to run the sci expression in a thread on the JVM and kill it if it takes too long or in a webworker in the browser and do the same.
Maybe I should drop the termination-safe option as well - not sure.
You could have a Malli schema defined for the app-db, with default and create the initial state from those, e.g.
(defn create [?schema]
{:validator (m/validator ?schema)
:explainer (m/explainer ?schema)
:initial (m/decode ?schema nil (mt/default-value-transformer))})
(create [:map {:default {}}
[:user [:map {:default {}}
[:first-name [:string {:min 1, :default ""}]]
[:last-name [:string {:min 1, :default ""}]]]]])
;{:validator #object[...],
; :explainer #object[...],
; :initial {:user {:first-name "", :last-name ""}}}
inferring is powerful, but not fully accurate, e.g. is something a vector of things of a tuple of always 2.(the mt/default-transformer
could have an option to create empty maps by default…)