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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user