Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct username check #124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public static String parsePlatformToSearch(String inputPlatform) throws IllegalV
public static String parseSearchName(String inputName) throws IllegalValueException {
requireNonNull(inputName);
String trimmedInputName = inputName.trim();
if (!Name.isValidName(trimmedInputName)) {
throw new IllegalValueException(Name.MESSAGE_NAME_CONSTRAINTS);
if (!trimmedInputName.matches(SocialMediaPlatform.USERNAME_VALIDATION_REGEX)) {
throw new IllegalValueException(SocialMediaPlatform.MESSAGE_USERNAME_CONSTRAINTS);
}
return trimmedInputName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
*/
public abstract class SocialMediaPlatform {

public static final String MESSAGE_USERNAME_CONSTRAINTS =
"Social media usernames should only contain alphanumeric characters, "
+ "underscore, and spaces, and it should not be blank";

public static final String USERNAME_VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum}_ ]*";

public static final String MESSAGE_PLATFORM_CONSTRAINTS =
"Platforms available are : \n"
+ "1) " + Facebook.PLATFORM_KEYWORD + " (alias: " + Facebook.PLATFORM_ALIAS + ")\n"
Expand Down