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
1 parent
faec460
commit b4ce832
Showing
3 changed files
with
16 additions
and
22 deletions.
There are no files selected for viewing
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,20 +1,17 @@ | ||
# jv-checked-exception | ||
|
||
--- | ||
Let's help user to register :) | ||
Let's help the user register :) | ||
|
||
We should implement the methods: | ||
We should implement the following methods: | ||
|
||
- `registerUser()` in UserService class | ||
- `validate()` in PasswordValidator class | ||
|
||
Method `validate()` should compare the `password` with `repeatPassword` and check | ||
if their length is more or equal to 10. If not, throw exception `PasswordValidationException` | ||
with message "Wrong passwords" (since it's our custom logic, let's create our own, **CHECKED**, exception | ||
because user can put any password and our service shouldn't be broken. We should handle not-valid case and return the understandable message). | ||
Method `validate()` should compare the `password` field with the `repeatPassword` field and check if their length is more or equal to 10. If not, throw exception `PasswordValidationException` with the message "Wrong passwords" (since it's our custom logic, let's create our own, **CHECKED**, exception because the user can put any password and our service shouldn't be broken. We should handle the not-valid case and return the understandable message). | ||
|
||
Method `registerUser()` should call the method `validate()` and handle the exception. | ||
If everything is ok, save user to the database (use method `saveUser()`), | ||
If everything is okay, save the user to the database (use method `saveUser()`), | ||
if not, print the message "Your passwords are incorrect. Try again.". | ||
|
||
#### [Try to avoid these common mistakes while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/exceptions/password-validation) | ||
#### [Try to avoid these common mistakes while solving task](./checklist.md) |
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
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