Skip to content

Instantly share code, notes, and snippets.

@jcromartie jcromartie/validators.clj Secret
Created Jul 29, 2011

Embed
What would you like to do?
(def common-login-validator
(validator
(required "Username is required" :username)
(required "Password is required" :password)
(regex "Password must be at least 6 characters long" :password #".{6,}")))
(def registration-validator
(validator
common-login-validator
(custom "Choose another username" :username (comp model/find-user :username))
(must-match "Password and confirmation must match" :password :confirm)))
(def login-validator
(validator
common-login-validator
(custom "Invalid username or password" :form #(not (model/authenticate
(:username %)
(:password %))))))
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.