All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.shifty.datamask.validate.ValidateInput Maven / Gradle / Ivy

The newest version!
package it.shifty.datamask.validate;

import javax.xml.bind.ValidationException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateInput {

    private static final Pattern VALID_EMAIL_ADDRESS_REGEX =
            Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);

    public static void validateEmail(String emailStr) throws ValidationException {
        Matcher matcher = VALID_EMAIL_ADDRESS_REGEX.matcher(emailStr);
        if (!matcher.find())
            throw new ValidationException(String.format("The input provided '{0}' does not seem a valid email", emailStr));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy