Thursday, February 12, 2015

Kata: Password validator in Clojure

I've just done the Password validator kata in Clojure.

It's a basic kata that, in my opinion, is very useful to think about how we choose the next test so that it helps us grow the code in small steps.

In this kata you have to validate a password.

The conditions that it has to fulfill to be valid are:
  • It should have more than 6 characters
  • It should contain at least one upper case character
  • It should contain at least one lower case character
  • It should contain at least one underscore
  • It should contain at least one numeric character
These are my tests using Midje:

and this is the final version of the code:

I used a mix of TDD and work on the REPL to code it.

To document the process I commited the code after every passing test and every refactoring and also commited the REPL history.

You can find the commits step by step here and the code in this repository in GitHub.

No comments:

Post a Comment