tdd-workshop-exercises/password_validator
fiatcode 3d94c96ed2 Initial commit: TDD Workshop exercises for participants
- Password Validator kata with starter code and tests
- Shopping Cart kata with starter code and tests
- FizzBuzz reference code (from live demo)
- Setup guide and TDD reference card
- No solutions included (participants implement themselves)
2026-03-10 15:37:58 +07:00
..
lib Initial commit: TDD Workshop exercises for participants 2026-03-10 15:37:58 +07:00
test Initial commit: TDD Workshop exercises for participants 2026-03-10 15:37:58 +07:00
pubspec.yaml Initial commit: TDD Workshop exercises for participants 2026-03-10 15:37:58 +07:00
README.md Initial commit: TDD Workshop exercises for participants 2026-03-10 15:37:58 +07:00

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?