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.
Modified PasswordValidationException.java, PasswordValidatior.java, U…
…serService.java
- Loading branch information
1 parent
223a4a7
commit 0fa0ba4
Showing
3 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
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,8 @@ | ||
package core.basesyntax; | ||
|
||
//write your code here | ||
public 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,16 @@ | ||
package core.basesyntax; | ||
|
||
public class PasswordValidator { | ||
public void validate(String password, String repeatPassword) { | ||
public void validate(String password, String repeatPassword) | ||
throws PasswordValidationException { | ||
//write your code here | ||
if (password == null || repeatPassword == null) { | ||
throw new PasswordValidationException("Wrong passwords"); | ||
} | ||
|
||
if (!password.equals(repeatPassword) || password.length() < 10 | ||
|| repeatPassword.length() < 10) { | ||
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