Fork me on GitHub

Hey, i have a question on accessing environment variables in project.clj and hope someone can help me out: I am writing a lein plugin, and i need to read something like {:config :env/CONFIG_A} in project.clj, but couldnt get it work. Looking at other projects (lein plugins) but I couldnt figure out how this works


@lumengxi: You might try the #C0AB48493 channel… not sure how active it is...


Generally, how should I validate arguments to a function? Has Spec affected the canonical way to to do it?


@bj it depends what sort of validation you’re talking about really… clojure.spec is really geared toward specification of data structures and thus "interfaces" that interact with them (APIs, subsystem boundaries, etc). You could use it for general validation but it’s probably overkill for some things (a lot of things perhaps).


There’s also the issue of what the result of that validation should be: is it a precondition of the function being called (i.e., should the function throw an exception if the argument is not valid?) or is it an "expected" and detectable error condition (e.g., does the argument identify a valid resource to which you have the appropriate access?)...


Can you give a more concrete example of validation that you have in mind?


I suppose more of what I’m looking for is ensuring that arguments passed to a function are of a reasonable type prior to the function being called, and throwing an exception if not valid.


For instance, should I ensure arg is a collection before executing the body of the function

(defn foo [arg]
  (map str arg))