Merge pull request #28 from informatik-ag-ngl/f/maximum_name_size

Added a method to get the maximum size allowed for user/ group names
This commit is contained in:
delvh 2020-06-27 20:26:11 +02:00 committed by GitHub
commit 2c414f8f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ import java.util.regex.Pattern;
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>Bounds.java</strong><br> * File: <strong>Bounds.java</strong><br>
* Created: <strong>25.06.2020</strong><br> * Created: <strong>25.06.2020</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
@ -18,7 +18,7 @@ public class Bounds {
/** /**
* The regular expression against which contact names should be validated. * The regular expression against which contact names should be validated.
* *
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public static final Pattern CONTACT_NAME_PATTERN = Pattern.compile("^\\w[a-zA-Z0-9-]{2,15}$"); public static final Pattern CONTACT_NAME_PATTERN = Pattern.compile("^\\w[a-zA-Z0-9-]{2,15}$");
@ -29,4 +29,12 @@ public class Bounds {
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public static boolean isValidContactName(String contactName) { return CONTACT_NAME_PATTERN.matcher(contactName).matches(); } 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; }
} }