Class ChangePasswordDtoValidator
java.lang.Object
com.app.validate.ChangePasswordDtoValidator
- All Implemented Interfaces:
Validator<ChangePasswordDto>
@Component
public class ChangePasswordDtoValidator
extends Object
implements Validator<ChangePasswordDto>
-
Constructor Summary
ConstructorsConstructorDescriptionChangePasswordDtoValidator
(List<String> passwordRegexs, int minLength) Constructs a ChangePasswordDtoValidator with password validation rules. -
Method Summary
Modifier and TypeMethodDescriptionvoid
validate
(ChangePasswordDto changePasswordDto) Validates the ChangePasswordDto object by checking: - If the DTO is null
-
Constructor Details
-
ChangePasswordDtoValidator
public ChangePasswordDtoValidator(@Value("${validate.regex.password}") List<String> passwordRegexs, @Value("${validate.password.min.length}") int minLength) Constructs a ChangePasswordDtoValidator with password validation rules.- Parameters:
passwordRegexs
- List of regex patterns to validate password complexityminLength
- Minimum length required for the password
-
-
Method Details
-
validate
Validates the ChangePasswordDto object by checking: - If the DTO is null. - If the current password meets complexity requirements. - If the new password and confirmation password are equal. - If the new password meets complexity requirements. - If the confirmation password meets complexity requirements. If any validation fails, a ValidationException is thrown containing all error messages.- Specified by:
validate
in interfaceValidator<ChangePasswordDto>
- Parameters:
changePasswordDto
- The DTO containing current, new and confirmation passwords- Throws:
ValidationException
- if any validation rule is violated
-