{"action":"created","issue":{"url":"https://api.github.com/repos/rentpath/clj-config/issues/15","labels_url":"https://api.github.com/repos/rentpath/clj-config/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/rentpath/clj-config/issues/15/comments","events_url":"https://api.github.com/repos/rentpath/clj-config/issues/15/events","html_url":"https://github.com/rentpath/clj-config/issues/15","id":125785567,"number":15,"title":"clj-config should validate environment vars","user":{"login":"briprowe","id":134571,"avatar_url":"https://avatars.githubusercontent.com/u/134571?v=3","gravatar_id":"","url":"https://api.github.com/users/briprowe","html_url":"https://github.com/briprowe","followers_url":"https://api.github.com/users/briprowe/followers","following_url":"https://api.github.com/users/briprowe/following{/other_user}","gists_url":"https://api.github.com/users/briprowe/gists{/gist_id}","starred_url":"https://api.github.com/users/briprowe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briprowe/subscriptions","organizations_url":"https://api.github.com/users/briprowe/orgs","repos_url":"https://api.github.com/users/briprowe/repos","events_url":"https://api.github.com/users/briprowe/events{/privacy}","received_events_url":"https://api.github.com/users/briprowe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-01-09T22:34:53Z","updated_at":"2016-01-12T15:01:47Z","closed_at":null,"body":"Right now clj-config simply checks for existence of declared environment vars. This is nice, but could be better. For example, if an environment variable is expected to be a URL clj-config should be able to validate that it's value is a valid URL.\r\n\r\nThis will require 2 major changes:\r\n\r\n1. We'll have to modify the `defconfig` macro to enable the user to specify a validator.\r\n2. We'll have to modify `clj-config.core/init!` to actually use the provided validators."},"comment":{"url":"https://api.github.com/repos/rentpath/clj-config/issues/comments/170939972","html_url":"https://github.com/rentpath/clj-config/issues/15#issuecomment-170939972","issue_url":"https://api.github.com/repos/rentpath/clj-config/issues/15","id":170939972,"user":{"login":"semperos","id":231375,"avatar_url":"https://avatars.githubusercontent.com/u/231375?v=3","gravatar_id":"","url":"https://api.github.com/users/semperos","html_url":"https://github.com/semperos","followers_url":"https://api.github.com/users/semperos/followers","following_url":"https://api.github.com/users/semperos/following{/other_user}","gists_url":"https://api.github.com/users/semperos/gists{/gist_id}","starred_url":"https://api.github.com/users/semperos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/semperos/subscriptions","organizations_url":"https://api.github.com/users/semperos/orgs","repos_url":"https://api.github.com/users/semperos/repos","events_url":"https://api.github.com/users/semperos/events{/privacy}","received_events_url":"https://api.github.com/users/semperos/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T15:01:47Z","updated_at":"2016-01-12T15:01:47Z","body":"@briprowe I appreciate you engaging my comment, and completely understood that it's a bit off-topic :no_entry: I included it here with the goal of limiting how many extra knobs are added to the existing `defconfig`. I'll open a separate issue for further discussion.\r\n\r\nIf you're going to add validation to `defconfig`, you might consider following suit with how [tools.cli](https://github.com/clojure/tools.cli) handles options (specifically the keyword parts, not the short/long option names):\r\n\r\n```clj\r\n(def cli-options\r\n  ;; An option with a required argument\r\n  [[\"-p\" \"--port PORT\" \"Port number\"\r\n    :default 80\r\n    :parse-fn #(Integer/parseInt %)\r\n    :validate [#(< 0 % 0x10000) \"Must be a number between 0 and 65536\"]]\r\n   ;; A non-idempotent option\r\n   [\"-v\" nil \"Verbosity level\"\r\n    :id :verbosity\r\n    :default 0\r\n    :assoc-fn (fn [m k _] (update-in m [k] inc))]\r\n   ;; A boolean option defaulting to nil\r\n   [\"-h\" \"--help\"]])\r\n```\r\n\r\nSee [Option Argument Validation](https://github.com/clojure/tools.cli#option-argument-validation) for the semantics here. The syntax here for `defconfig` could still be vector based overall, with either the optional map (as you wrote @briprowe) or with optional key-value entries in a varargs style (as tools.cli does). I'd definitely stick with one of the two (as opposed to just accepting either a schema or a fn), so you can have additional optional config entries like `:default` or `:parse-fn` for example."}}