![JAR search and dependency download from the Maven repository](/logo.png)
org.droitateddb.validation.PatternValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
droitatedDB is a lightweight framework, which frees you from the burden of dealing with Androids SQLite
database directly if you don't want to
and let's you access it directly if you have to.
The newest version!
package org.droitateddb.validation;
/**
* Implementation of the @Pattern validation annotation
*
* @author Falk Appel
* @author Alexander Frank
*/
public class PatternValidator implements CustomValidator {
public static final int ERROR_CODE = 5;
@Override
public ValidationResult onValidate(Pattern annotation, String toByValidated) {
if (toByValidated == null) {
return ValidationResult.valid();
}
if (java.util.regex.Pattern.compile(annotation.value()).matcher(toByValidated).matches()) {
return ValidationResult.valid();
}
return ValidationResult.invalid(ERROR_CODE, "The given data doesn't match the pattern " + annotation.value());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy