{"action":"created","issue":{"url":"https://api.github.com/repos/michaelklishin/validateur/issues/39","labels_url":"https://api.github.com/repos/michaelklishin/validateur/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/michaelklishin/validateur/issues/39/comments","events_url":"https://api.github.com/repos/michaelklishin/validateur/issues/39/events","html_url":"https://github.com/michaelklishin/validateur/issues/39","id":55036928,"number":39,"title":"Data coercion ","user":{"login":"vincentjames501","id":396866,"avatar_url":"https://avatars.githubusercontent.com/u/396866?v=3","gravatar_id":"","url":"https://api.github.com/users/vincentjames501","html_url":"https://github.com/vincentjames501","followers_url":"https://api.github.com/users/vincentjames501/followers","following_url":"https://api.github.com/users/vincentjames501/following{/other_user}","gists_url":"https://api.github.com/users/vincentjames501/gists{/gist_id}","starred_url":"https://api.github.com/users/vincentjames501/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincentjames501/subscriptions","organizations_url":"https://api.github.com/users/vincentjames501/orgs","repos_url":"https://api.github.com/users/vincentjames501/repos","events_url":"https://api.github.com/users/vincentjames501/events{/privacy}","received_events_url":"https://api.github.com/users/vincentjames501/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-21T15:54:46Z","updated_at":"2015-01-21T16:28:59Z","closed_at":null,"body":"I chose to use Validateur over another tool like Schema due to the fact that the error messages are easily human readable. While I realize this isn't what Validateur is all about, it would be nice to add a new namespace that can do data coercion for you.  I'm thinking of something like the following use case:\r\n\r\nConsider a JSON POST body of:\r\n\r\n```json\r\n{\"subscriptionSize\": 250}\r\n```\r\n\r\nVersus a form encoded POST of:\r\n\r\n```\r\n?subscriptionSize=250\r\n```\r\n\r\nIn the case of JSON (using ring and popular middleware), the type of subscriptionSize is a number and in the case of the form encoded params the type is a String.\r\n\r\nThis causes a validation such as below to be inconsistent where it would validate correctly for the JSON request but not the form encoded request:\r\n\r\n```clojure\r\n(def ^:private my-validateur\r\n  (validation-set\r\n    (presence-of #{:other-param :subscription-size} :any true)\r\n    (numericality-of :subscription-size :only-integer false :gte 0 :allow-nil true)))\r\n```\r\n\r\nIt would be nice if Validator could create a new namespace that can coerce your data depending on your validation specified. Something like the following:\r\n\r\n```clojure\r\n(defn handle-request \r\n  [request]\r\n  (let [coerced-params (validateur.coercer/coerce my-validateur (:params request))\r\n         errors (my-validateur coerced-params)]\r\n    (if (empty? errors)\r\n      (do-stuff coerced-params)\r\n      (reject-stuff errors))))\r\n```\r\n\r\nThis is just intended to spark a conversation. Thoughts?"},"comment":{"url":"https://api.github.com/repos/michaelklishin/validateur/issues/comments/70869203","html_url":"https://github.com/michaelklishin/validateur/issues/39#issuecomment-70869203","issue_url":"https://api.github.com/repos/michaelklishin/validateur/issues/39","id":70869203,"user":{"login":"michaelklishin","id":1090,"avatar_url":"https://avatars.githubusercontent.com/u/1090?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelklishin","html_url":"https://github.com/michaelklishin","followers_url":"https://api.github.com/users/michaelklishin/followers","following_url":"https://api.github.com/users/michaelklishin/following{/other_user}","gists_url":"https://api.github.com/users/michaelklishin/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelklishin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelklishin/subscriptions","organizations_url":"https://api.github.com/users/michaelklishin/orgs","repos_url":"https://api.github.com/users/michaelklishin/repos","events_url":"https://api.github.com/users/michaelklishin/events{/privacy}","received_events_url":"https://api.github.com/users/michaelklishin/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T16:28:59Z","updated_at":"2015-01-21T16:28:59Z","body":"How would `v.coercer/coerce` work in the provided example? And for what data types?"}}