Class NewEmailDtoValidator

java.lang.Object
com.app.validate.NewEmailDtoValidator
All Implemented Interfaces:
Validator<NewEmailDto>

@Component public class NewEmailDtoValidator extends Object implements Validator<NewEmailDto>
Validator implementation for NewEmailDto objects. Validates the new email, confirm email fields and current password against configured regex patterns.
  • 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 format
      passwordRegexs - list of regex patterns for validating password complexity
      minLength - minimum length required for the password
  • Method Details

    • validate

      public void validate(NewEmailDto newEmailDto)
      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 interface Validator<NewEmailDto>
      Parameters:
      newEmailDto - the NewEmailDto object to validate
      Throws:
      ValidationException - if validation errors are found