added isNameValid and isUsernameValid methods to ValidationUtil

This commit is contained in:
Sebastian Sdorra
2011-08-06 13:36:51 +02:00
parent 3d97e1589a
commit 215eb289ad
2 changed files with 82 additions and 0 deletions

View File

@@ -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
*