1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-12 17:26:13 +00:00

Allow the . (dot) and @ (at) character in usernames (#637)

Co-authored-by: Uli Koeth <uli@kiot.eu>
This commit is contained in:
Uli
2022-05-05 17:48:45 +02:00
committed by GitHub
parent c6a685d7c0
commit 90d5bc8de7
4 changed files with 16 additions and 8 deletions

View File

@@ -21,6 +21,8 @@ public class ValidationUtil {
private static Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9_]+");
private static Pattern USERNAME_PATTERN = Pattern.compile("[a-zA-Z0-9_@\\.]+");
/**
* Checks that the argument is not null.
*
@@ -152,6 +154,12 @@ public class ValidationUtil {
}
}
public static void validateUsernamepattern(String s, String name) throws ClientException {
if (!USERNAME_PATTERN.matcher(s).matches()) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must have only alphanumeric, underscore characters or @ and .", name));
}
}
public static void validateRegex(String s, String name, String regex) throws ClientException {
if (!Pattern.compile(regex).matcher(s).matches()) {
throw new ClientException("ValidationError", MessageFormat.format("{0} must match {1}", name, regex));