Skip to content

Instantly share code, notes, and snippets.

@ibdknox
Created June 21, 2011 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibdknox/1039191 to your computer and use it in GitHub Desktop.
Save ibdknox/1039191 to your computer and use it in GitHub Desktop.
get started step 4
;; add a value to the session
(defpage "/login" {}
(session/put! :admin true)
(layout
[:p "Are you loggedin? "]
[:p (session/get :admin)]))
;; set a cookie and get its value
(defpage "/cookie" []
(cookie/put! :noir "stuff")
(let [v (cookie/get :noir)]
(layout
[:p "You created a cookie:"]
[:p "Value " v])))
;; validate our math, if the first statement
;; is false, it fails validation and the error
;; is added for the given key.
(defpage "/validate" []
(vali/rule (= 3 3)
[:math "3 != 3"])
(vali/rule (= 1 2)
[:math "1 != 2"])
(layout
[:p "Let's check your math: "]
[:p (str (vali/get-errors :math))]))
@cldwalker
Copy link

for newbs, would help to define the proper the requires so the examples just work i.e. for the last example

(:require [noir.validation :as val])

I'd give you a pull request for the website but that's not really possible with gists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment