Fork me on GitHub
#clojure-spec
<
2022-05-05
>
pavlosmelissinos12:05:33

I have some kind of user configuration in the form of edn files. They're quite complex and rigorously spec'd, so I want to help the users identify potential problems (e.g. typos, settings that are no longer used etc), to help them manage this complexity. Assuming that it's not feasible at the moment to simplify the maps and given that spec doesn't support closed maps, what's the best way to do the above? There's a bunch of multi-specs in the specs that seem to break libraries like spell-spec and spec-tools. Example: given (s/def ::m (s/keys :req [:foo] :opt [::bar])) I want to get some warning for (def m {:foo 1 :baar 1}) Reasoning: In my use case it's more likely that baar is a typo, than a correct key that is used somewhere else. I have no way of knowing without asking the user, so how can I do that? I understand that closed maps are an antipattern in Clojure but the use case is real unfortunately. Happy to consider alternatives in any case! Thanks!

pavlosmelissinos12:05:42

Oooh, didn't think of that, thanks! 🙂