use of org.apache.commons.validator.routines.RegexValidator in project Asqatasun by Asqatasun.
the class CreateContractFormValidator method checkContractUrl.
/**
*
* @param userSubscriptionCommand
* @param errors
* @return
*/
private boolean checkContractUrl(CreateContractCommand createContractCommand, Errors errors) {
String url = createContractCommand.getContractUrl().trim();
if (StringUtils.isBlank(url)) {
return true;
}
String[] schemes = { "http", "https" };
long validatorOptions = UrlValidator.ALLOW_2_SLASHES + UrlValidator.ALLOW_LOCAL_URLS;
UrlValidator urlValidator = new UrlValidator(schemes, new RegexValidator(".*"), validatorOptions);
if (!urlValidator.isValid(url)) {
errors.rejectValue(CONTRACT_URL_KEY, INVALID_URL_KEY);
return false;
}
return true;
}
Aggregations