tdd-workshop/password_validator/README.md
fiatcode c3355063f2 Initial commit: Complete TDD workshop materials
- Workshop documentation (WORKSHOP_PLAN, FACILITATOR_GUIDE, etc.)
- FizzBuzz kata with demo script (git history to be recreated)
- Password Validator kata with demo script and solution
- Shopping Cart kata with demo script and solution
- Setup guide and TDD reference card for participants
2026-03-10 15:32:21 +07:00

1.4 KiB
Raw Blame History

Feature A — Password Validator

Your goal

Implement PasswordValidator using strict TDD. Do not write any production code before you have a failing test.

Rules to implement (in order)

Step Rule Error message
1 At least 8 characters long Must be at least 8 characters long
2 At least one uppercase letter (AZ) Must contain at least one uppercase letter
3 At least one digit (09) Must contain at least one digit
4 At least one special character (!@#$%^&*) Must contain at least one special character (!@#$%^&*)
5 No spaces Must not contain spaces
6 All errors reported at once (refactor)

The rhythm — repeat for every rule

1. Uncomment the next test → run → watch it FAIL (Red)
2. Write the minimum code to make it pass → run → GREEN
3. Refactor if needed → run → still GREEN
4. Move to the next test

Running the tests

dart pub get
dart test

Files

  • lib/password_validator.dart — your implementation goes here
  • test/password_validator_test.dart — uncomment tests one at a time

Hint for Step 6 (the refactor insight)

Once all 5 rules pass, you'll likely have 5 separate if blocks in validate(). Think about how to represent each rule as data instead of code. What if each rule were just a function in a list?