Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created July 29, 2011 12:41
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 jcromartie/660666aff8742ab77ad9 to your computer and use it in GitHub Desktop.
Save jcromartie/660666aff8742ab77ad9 to your computer and use it in GitHub Desktop.
(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