mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-04-04 19:28:52 +02:00
added isNameValid and isUsernameValid methods to ValidationUtil
This commit is contained in:
@@ -48,6 +48,12 @@ public class ValidationUtil
|
||||
private static final String REGEX_MAIL =
|
||||
"^[A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6}$";
|
||||
|
||||
/** Field description */
|
||||
private static final String REGEX_NAME = "^[A-z0-9\\.\\-_]+$";
|
||||
|
||||
/** Field description */
|
||||
private static final String REGEX_USERNAME = "^[A-z0-9\\.\\-_@]+$";
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -80,6 +86,21 @@ public class ValidationUtil
|
||||
return value.matches(REGEX_MAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNameValid(String name)
|
||||
{
|
||||
AssertUtil.assertIsNotNull(name);
|
||||
|
||||
return name.matches(REGEX_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -112,6 +133,21 @@ public class ValidationUtil
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param username
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isUsernameValid(String username)
|
||||
{
|
||||
AssertUtil.assertIsNotNull(username);
|
||||
|
||||
return username.matches(REGEX_USERNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user