nl.vpro.validation.LocationValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of media-domain Show documentation
Show all versions of media-domain Show documentation
The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it.
It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.
package nl.vpro.validation;
import java.net.URISyntaxException;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
/**
* @author Michiel Meeuwissen
* @since 3.7
*/
public class LocationValidator implements ConstraintValidator {
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
if(value == null) {
return true;
}
try {
java.net.URI uri = new java.net.URI(value);
if (uri.getScheme() == null || uri.getHost() == null) {
return false;
}
return true;
} catch(URISyntaxException e) {
return false;
}
}
}