From 1a037c1927174a9fdc4677e7b1508ce06cc46861 Mon Sep 17 00:00:00 2001 From: binsky Date: Sat, 5 Feb 2022 14:31:22 +0100 Subject: [PATCH] implement check for minimum password length --- src/main/java/PasswordValidator.java | 3 ++- src/test/java/PasswordValidatorTest.java | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/PasswordValidator.java b/src/main/java/PasswordValidator.java index 3825cd5..e469c92 100644 --- a/src/main/java/PasswordValidator.java +++ b/src/main/java/PasswordValidator.java @@ -1,6 +1,7 @@ public class PasswordValidator { + int minLength = 6; public boolean validate(String password) { - return false; + return password.length() >= minLength; } } diff --git a/src/test/java/PasswordValidatorTest.java b/src/test/java/PasswordValidatorTest.java index 5af0485..e40fa23 100644 --- a/src/test/java/PasswordValidatorTest.java +++ b/src/test/java/PasswordValidatorTest.java @@ -8,5 +8,8 @@ class PasswordValidatorTest { void validate() { PasswordValidator passwordValidator = new PasswordValidator(); assertFalse(passwordValidator.validate("")); + + // test minimum password length + assertTrue(passwordValidator.validate("abcdef")); } -} \ No newline at end of file +}