
validator.person.name.NameValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of validators Show documentation
Show all versions of validators Show documentation
A set of validators for the person, credit card and address domain.
The newest version!
package validator.person.name;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* This class validates a person name.
*
* @author Jhonathan Camamacho
*
*/
public class NameValidator implements ConstraintValidator {
private Pattern pattern = Pattern.compile("^[A-Za-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÊÍÏÓÔÕÖÚÇÑ ]+$");
@Override
public void initialize(Name constraintAnnotation) {
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
Matcher m = pattern.matcher(value);
return m.matches();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy