This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/common/src/main/java/envoy/util/Bounds.java

42 lines
1.0 KiB
Java

package envoy.util;
import java.util.regex.Pattern;
/**
* Implements contact name validation.
*
* @author Kai S. K. Engelbart
* @since Envoy Common v0.1-beta
*/
public final class Bounds {
private Bounds() {}
/**
* The regular expression against which contact names should be validated.
*
* @since Envoy Common v0.1-beta
*/
public static final Pattern CONTACT_NAME_PATTERN = Pattern.compile("^\\w[a-zA-Z0-9-]{2,15}$");
// KAI: Trust of Chain - das berühmte Konzept aus der Kryptographie
/**
* @param contactName the contact name to validate
* @return {@code true} if the given contact name is valid
* @since Envoy Common v0.1-beta
*/
public static boolean isValidContactName(String contactName) {
return CONTACT_NAME_PATTERN.matcher(contactName).matches();
}
/**
* @return the maximum size allowed for a user/ group name.
* @apiNote has to be updated manually if {@link Bounds#CONTACT_NAME_PATTERN} gets updated.
* @since Envoy Common v0.1-beta
*/
public static int maximumUsernameSize() {
return 16;
}
}