Skip to content

Commit

Permalink
Realization of task
Browse files Browse the repository at this point in the history
  • Loading branch information
forzen123212 committed Oct 1, 2023
1 parent a4b760c commit e79bffa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package core.basesyntax;

public class PasswordValidationException extends Exception {
PasswordValidationException() {
super();
}
import java.io.IOException;

PasswordValidationException(String message) {
public class PasswordValidationException extends IOException {
public PasswordValidationException(String message) {
super(message);
}
}
4 changes: 3 additions & 1 deletion src/main/java/core/basesyntax/PasswordValidator.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package core.basesyntax;

public class PasswordValidator {
private static final String ERROR_MESSAGE = "Wrong passwords";

public void validate(String password, String repeatPassword)
throws PasswordValidationException {
if (((password == null && repeatPassword == null) || password.length() == 0)
|| (password.equals(repeatPassword) && password.length() < 10)
|| !password.equals(repeatPassword)) {
throw new PasswordValidationException("Wrong passwords");
throw new PasswordValidationException(ERROR_MESSAGE);
}
}
}

0 comments on commit e79bffa

Please sign in to comment.