Clojurians
#beginners
<
2016-08-24
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

lumengxi01:08:45

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

seancorfield05:08:55

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

lumengxi05:08:14

ok thanks @seancorfield

bj19:08:29

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

seancorfield21:08:22

@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).

seancorfield21:08:55

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?)...

seancorfield21:08:29

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

bj21:08:20

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.

bj21:08:55

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

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