All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.common.cfg.HostnameValidator Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.common.cfg;

import java.util.regex.Pattern;

import io.bdeploy.common.cfg.Configuration.ConfigValidator;
import io.bdeploy.common.cfg.Configuration.ValidationMessage;

/**
 * Checks hostname value according to https://tools.ietf.org/html/rfc1123 2.1
 *
 * @see #HOSTNAME_PATTERN
 */
@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 test(String value) {
        return HOSTNAME_PATTERN.matcher(value.toLowerCase()).matches();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy