From 903f5f1e805676ebab03cbd55b8bb5a08fc6747b Mon Sep 17 00:00:00 2001 From: OksanaEnko <132217385+OksanaEnko@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:27:00 +0200 Subject: [PATCH] Update PasswordValidator.java --- src/main/java/core/basesyntax/PasswordValidator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/core/basesyntax/PasswordValidator.java b/src/main/java/core/basesyntax/PasswordValidator.java index eac65cfa..b31fd1d2 100644 --- a/src/main/java/core/basesyntax/PasswordValidator.java +++ b/src/main/java/core/basesyntax/PasswordValidator.java @@ -4,11 +4,11 @@ public class PasswordValidator { private static final int MIN_PASSWORD_LENGTH = 8; public void validate(String password, String repeatPassword) throws PasswordValidationException { - if (password == null || repeatPassword == null) { - throw new PasswordValidationException("Passwords cannot be null"); - } - if (password.length() < MIN_PASSWORD_LENGTH || !password.equals(repeatPassword)) { + if (password == null || repeatPassword == null || + password.length() < MIN_PASSWORD_LENGTH || + !password.equals(repeatPassword)) { throw new PasswordValidationException("Wrong passwords"); } } } +