Class NewEmailDtoValidator
java.lang.Object
com.app.validate.NewEmailDtoValidator
- All Implemented Interfaces:
Validator<NewEmailDto>
Validator implementation for NewEmailDto objects.
Validates the new email, confirm email fields and current password against configured regex patterns.
-
Constructor Summary
ConstructorsConstructorDescriptionNewEmailDtoValidator
(String emailRegex, List<String> passwordRegexs, int minLength) Constructs a NewEmailDtoValidator with the provided validation parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
validate
(NewEmailDto newEmailDto) Validates the given NewEmailDto object.
-
Constructor Details
-
NewEmailDtoValidator
public NewEmailDtoValidator(@Value("${validate.regex.email}") String emailRegex, @Value("${validate.regex.password}") List<String> passwordRegexs, @Value("${validate.password.min.length}") int minLength) Constructs a NewEmailDtoValidator with the provided validation parameters.- Parameters:
emailRegex
- regex pattern for validating email formatpasswordRegexs
- list of regex patterns for validating password complexityminLength
- minimum length required for the password
-
-
Method Details
-
validate
Validates the given NewEmailDto object. Checks if the DTO is null, validates new email and confirm email fields against the email regex, and validates the current password using configured password regexes and minimum length. Collects errors and throws ValidationException if any validation fails.- Specified by:
validate
in interfaceValidator<NewEmailDto>
- Parameters:
newEmailDto
- the NewEmailDto object to validate- Throws:
ValidationException
- if validation errors are found
-