Skip to content

Commit

Permalink
Update PasswordValidator.java
Browse files Browse the repository at this point in the history
  • Loading branch information
OksanaEnko authored Oct 11, 2024
1 parent 42d7c6a commit 8f4943b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/core/basesyntax/PasswordValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ public class PasswordValidator {
private static final int MIN_PASSWORD_LENGTH = 10;

public void validate(String password, String repeatPassword) throws PasswordValidationException {
if (password == null || repeatPassword == null) {
if (password == null
|| repeatPassword == null) {
throw new PasswordValidationException("Wrong passwords");
}
if (password.length() < MIN_PASSWORD_LENGTH || repeatPassword.length() < MIN_PASSWORD_LENGTH) {
if (password.length() < MIN_PASSWORD_LENGTH
|| repeatPassword.length() < MIN_PASSWORD_LENGTH) {
throw new PasswordValidationException("Wrong passwords");
}

if (!password.equals(repeatPassword)) {
throw new PasswordValidationException("Wrong passwords");
}
Expand Down

0 comments on commit 8f4943b

Please sign in to comment.