Closed Ramblurr closed 4 years ago
From slack
@kwrooijen 16:41 That's a bug it seems What's interesting though is that child-properties is getting a nil as argument. That shouldn't happen The problem is most likely here:
(defn child "Get the child `k` from `?model`. Returns `nil` if not found." [?model k] (->> (?model->model ?model) (m/children) (reduce (fn [_ child] (when (#{k} (first child)) (reduced child))) nil)))
It expects fields to be of the form
[key ?props spec]
But since you're giving a keyword, it doesn't know how to handle it Maybe Malli has a function to actually do this for me, instead of using reduce by hand Also I think Gungnir needs to handle Model registries
Note that this is an issue with the latest version of Malli (Since SNAPSHOT doesn't have the qualified keyword child feature yet https://github.com/metosin/malli/pull/239)
If this is to be fixed Gungnir will have to lock Malli to a specific commit instead of SNAPSHOT (Which isn't a bad idea at all).
I think that's a good idea. I am indeed using malli master branch in my gungir project. I propose we lock to the latest malli commit, document that, and then periodically update it until a stable malli release happens.
I use the https://github.com/reifyhealth/lein-git-down plugin to achieve this. I suppose it will work with libraries like gungnir too.
I'll take a look at the options for git dependencies in libraries. In the past I used lein-git-down
for (private) git dependencies and I had to manually add them to the top level project. That isn't really desired behavior but probably that's fixable.
The goal is to separate out the actual data specs, so I can re-use them in places where gungnir isn't involved. The attached example works, until you enable instrumentation.. then there is a spec violation. But it does seem to work as intended with spec disabled. You can also trigger a spec error from gungnir earlier by replacing the
(m/spec User)
withUser
on line 13. gungnir doesn't seem to like the referenced schema.