io.bdeploy.common.cfg.HostnameValidator 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
Public API including dependencies, ready to be used for integrations and plugins.
package io.bdeploy.common.cfg;
import java.util.regex.Pattern;
import io.bdeploy.common.cfg.Configuration.ConfigValidator;
import io.bdeploy.common.cfg.Configuration.ValidationMessage;
/**
* Validate hostname value according to https://tools.ietf.org/html/rfc1123 2.1 which extends
*/
@ValidationMessage("Not a valid host name: %s")
public class HostnameValidator implements ConfigValidator {
private static final Pattern HOSTNAME_PATTERN = Pattern
.compile("(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9][a-z0-9-]{0,61}[a-z0-9]");
@Override
public boolean validate(String value) {
return HOSTNAME_PATTERN.matcher(value.toLowerCase()).matches();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy