public static final String REGEX_PARAM = "regex";
@Override
public String validate(String data, Map<String, String> arguments) {
if (data == null || arguments == null) {
throw new SlingValidationException("Cannot perform data validation with null parameters");
}
String regex = arguments.get(REGEX_PARAM);
if (regex == null) {
throw new SlingValidationException("Mandatory " + REGEX_PARAM + " is missing from the arguments map.");
}
Pattern pattern = Pattern.compile(regex);
if (pattern.matcher(data).matches()) {
return null;
}