Class EmailValidator
java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.validators.EmailValidator
- All Implemented Interfaces:
UserValidator
Validator that checks if a given email address is already registered in the system.
Implements the UserValidator
interface and queries the database using UserRepository
.
-
Constructor Summary
ConstructorsConstructorDescriptionEmailValidator
(UserRepository userRepository) Constructs anEmailValidator
with the specifiedUserRepository
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
validate
(UsersRequestDTO dto) Validates whether the email in the givenUsersRequestDTO
already exists.
-
Constructor Details
-
EmailValidator
Constructs anEmailValidator
with the specifiedUserRepository
.- Parameters:
userRepository
- the repository used to check if the email already exists.
-
-
Method Details
-
validate
Validates whether the email in the givenUsersRequestDTO
already exists.- Specified by:
validate
in interfaceUserValidator
- Parameters:
dto
- the DTO containing the user's email to validate.- Throws:
EmailAlreadyExistsException
- if the email is already registered.
-