Class ChangePasswordDtoValidator

java.lang.Object
com.app.validate.ChangePasswordDtoValidator
All Implemented Interfaces:
Validator<ChangePasswordDto>

@Component public class ChangePasswordDtoValidator extends Object implements Validator<ChangePasswordDto>
  • 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 complexity
      minLength - Minimum length required for the password
  • Method Details

    • validate

      public void validate(ChangePasswordDto changePasswordDto)
      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 interface Validator<ChangePasswordDto>
      Parameters:
      changePasswordDto - The DTO containing current, new and confirmation passwords
      Throws:
      ValidationException - if any validation rule is violated