Created
November 19, 2017 05:53
-
-
Save shakdwipeea/2bf4b499f9f78cf18a9cd2c06c0acf02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: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