Skip to content

Instantly share code, notes, and snippets.

@ibdknox ibdknox/step4.clj
Created Jun 21, 2011

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented May 4, 2012

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
You can’t perform that action at this time.