Skip to content

Commit

Permalink
fix PasswordValidator.java
Browse files Browse the repository at this point in the history
  • Loading branch information
OksanaEnko authored Oct 9, 2024
1 parent 22685c2 commit 2fe5d16
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/core/basesyntax/PasswordValidator.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package core.basesyntax;

public class PasswordValidator {
private static final int MIN_PASSWORD_LENGTH = 8;
public void validate(String password, String repeatPassword) {

public void validate(String password, String repeatPassword) throws PasswordValidationException {
if (password == null || repeatPassword == null ||
password.length() < MIN_PASSWORD_LENGTH ||
!password.equals(repeatPassword)) {
public void validate(String password, String repeatPassword)
throws PasswordValidationExeption {

if (password == null || repeatPassword == null) {
throw new PasswordValidationExeption ("Wrong passwords");
}
if password.length() < 10 || repeatPassword.length() < 10) {
throw new PasswordValidationExeption ("Wrong passwords");
}
if (!password.equals(repeatPassword)) {
throw new PasswordValidationException("Wrong passwords");
}
}
Expand Down

0 comments on commit 2fe5d16

Please sign in to comment.