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 anEmailValidatorwith the specifiedUserRepository. -
Method Summary
Modifier and TypeMethodDescriptionvoidvalidate(UsersRequestDTO dto) Validates whether the email in the givenUsersRequestDTOalready exists.
-
Constructor Details
-
EmailValidator
Constructs anEmailValidatorwith the specifiedUserRepository.- Parameters:
userRepository- the repository used to check if the email already exists.
-
-
Method Details
-
validate
Validates whether the email in the givenUsersRequestDTOalready exists.- Specified by:
validatein interfaceUserValidator- Parameters:
dto- the DTO containing the user's email to validate.- Throws:
EmailAlreadyExistsException- if the email is already registered.
-