generated from mate-academy/jv-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6
src/main/java/core/basesyntax/PasswordValidationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
package core.basesyntax; | ||
|
||
//write your code here | ||
class PasswordValidationException extends Exception { | ||
public PasswordValidationException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package core.basesyntax; | ||
|
||
public class PasswordValidator { | ||
public void validate(String password, String repeatPassword) { | ||
//write your code here | ||
public void validate(String password, String repeatPassword) | ||
throws PasswordValidationException { | ||
if (password == null || repeatPassword == null | ||
|| password.length() < 10 || repeatPassword.length() < 10 | ||
|| !repeatPassword.equals(password)) { | ||
throw new PasswordValidationException("Wrong passwords"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters