Skip to content

Instantly share code, notes, and snippets.

@shakdwipeea
Created November 19, 2017 05:53
Show Gist options
  • Save shakdwipeea/2bf4b499f9f78cf18a9cd2c06c0acf02 to your computer and use it in GitHub Desktop.
Save shakdwipeea/2bf4b499f9f78cf18a9cd2c06c0acf02 to your computer and use it in GitHub Desktop.
(:require [clojure.spec.alpha :as s])
(s/def ::id string?)
(s/def ::link uri?)
(s/def ::tag (s/and string?
(complement empty?)))
(s/def ::tags (s/coll-of ::tag
:distinct true))
(s/def ::link-data (s/keys :req-un [::id ::link ::tags]))
(def a-tag {:id "asdasd"
:link "http://dsfdfdsfs.com"
:tags ["asd" "sadas"]})
(let [parsed (s/conform ::link-data a-tag)]
(if (= parsed ::s/invalid)
(throw (ex-info "Invalid input"
{:reason (expound/expound-str ::link-data a-tag)}))
(println (db/query {:select :id
:from :users}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment