Class EmailDtoValidator

java.lang.Object
com.app.validate.EmailDtoValidator
All Implemented Interfaces:
Validator<EmailDto>

@Component public class EmailDtoValidator extends Object implements Validator<EmailDto>
Validator implementation for EmailDto objects. Validates the email field against a configured regex pattern.
  • Constructor Details

    • EmailDtoValidator

      public EmailDtoValidator(@Value("${validate.regex.email}") String emailRegex)
      Constructs an EmailDtoValidator with the provided email regex pattern.
      Parameters:
      emailRegex - regex pattern for validating email format
  • Method Details

    • validate

      public void validate(EmailDto emailDto)
      Validates the given EmailDto object. Checks if the DTO is null and if the email field matches the email regex pattern. Collects errors and throws ValidationException if any validation fails.
      Specified by:
      validate in interface Validator<EmailDto>
      Parameters:
      emailDto - the EmailDto object to validate
      Throws:
      ValidationException - if validation errors are found