Skip to content

Commit

Permalink
Revert "[nus-cs2103-AY1617S2#117] Names with unicode characters are t…
Browse files Browse the repository at this point in the history
…reated as invalid (nus-cs2103-AY1617S2#138)"

This reverts commit 70f60ba.
  • Loading branch information
joelleejh committed Feb 8, 2017
1 parent 70f60ba commit d2bbd49
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/seedu/addressbook/data/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Address(String address, boolean isPrivate) throws IllegalValueException {
}

/**
* Returns true if a given string is a valid person email.
* Returns true if a given string is a valid person address.
*/
public static boolean isValidAddress(String test) {
return test.matches(ADDRESS_VALIDATION_REGEX);
Expand Down
11 changes: 9 additions & 2 deletions src/seedu/addressbook/data/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
public class Name {

public static final String EXAMPLE = "John Doe";
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphabetic characters";
public static final String NAME_VALIDATION_REGEX = "[\\p{Alpha} ]+";
public static final String MESSAGE_NAME_CONSTRAINTS = "Names should consist of letters, "
+ "spaces, numbers, ', - or .";
public static final String NAME_VALIDATION_REGEX = "^[\\p{L}0-9 .'-]+$";
// In the above:
// \\p{L} matches any unicode letter (like German name with accents)
// . used to match dots in the name E.g., John Paul Jr.
// ' is used to match names like d'Souza
// - is used to match names like Jolie-Pitt

public final String fullName;

/**
Expand Down
74 changes: 73 additions & 1 deletion test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
|| Tags names should be alphanumeric
|| ===================================================
|| Enter command: || [Command entered: add []\[;] p/12345 e/valid@e.mail a/valid, address]
|| Person names should be spaces or alphabetic characters
|| Names should consist of letters, spaces, numbers, ', - or .
|| ===================================================
|| Enter command: || [Command entered: add Valid Name p/not_numbers e/valid@e.mail a/valid, address]
|| Person phone numbers should only contain numbers
Expand Down Expand Up @@ -297,6 +297,78 @@
||
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Name with'arc p/99999999 e/name@arc.com a/1 long, #01-valid address, 890765]
|| New person added: Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
||
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add John-Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25]
|| New person added: John-Doe Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| 2. John-Doe Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
||
|| 2 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add John-Doe jr. p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25]
|| New person added: John-Doe jr. Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| 2. John-Doe Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 3. John-Doe jr. Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
||
|| 3 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add Björn Borg p/98765432 e/borg@gmail.com a/311, Clementi Ave 2, #02-25]
|| New person added: Björn Borg Phone: 98765432 Email: borg@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| 2. John-Doe Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 3. John-Doe jr. Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 4. Björn Borg Phone: 98765432 Email: borg@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
||
|| 4 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add José Eduardo p/98765432 e/borg@gmail.com a/311, Clementi Ave 2, #02-25]
|| New person added: José Eduardo Phone: 98765432 Email: borg@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. Name with'arc Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| 2. John-Doe Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 3. John-Doe jr. Phone: 98765432 Email: johnd@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 4. Björn Borg Phone: 98765432 Email: borg@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
|| 5. José Eduardo Phone: 98765432 Email: borg@gmail.com Address: 311, Clementi Ave 2, #02-25 Tags:
||
|| 5 persons listed!
|| ===================================================
|| Enter command: || [Command entered: clear]
|| Address book has been cleared!
|| ===================================================
|| Enter command: || [Command entered: list]
||
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: add George the 3rd p/99999999 e/name@arc.com a/1 long, #01-valid address, 890765]
|| New person added: George the 3rd Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
|| ===================================================
|| Enter command: || [Command entered: list]
|| 1. George the 3rd Phone: 99999999 Email: name@arc.com Address: 1 long, #01-valid address, 890765 Tags:
||
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: clear]
|| Address book has been cleared!
|| ===================================================
|| Enter command: || [Command entered: list]
||
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: exit]
|| Exiting Address Book as requested ...
|| ===================================================
Expand Down
44 changes: 44 additions & 0 deletions test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,50 @@
# clears all
clear
list

##########################################################
# test new regex for name
##########################################################
# name with quote character
add Name with'arc p/99999999 e/name@arc.com a/1 long, #01-valid address, 890765
list

# name with hyphen in between
add John-Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25
list

# name with dot in it
add John-Doe jr. p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25
list

# name with unicode character in it
add Björn Borg p/98765432 e/borg@gmail.com a/311, Clementi Ave 2, #02-25
list

# name with another unicode character
add José Eduardo p/98765432 e/borg@gmail.com a/311, Clementi Ave 2, #02-25
list

##########################################################
# clear all test entries
##########################################################

clear
list

##########################################################
# test new regex for name
##########################################################
# name with number character
add George the 3rd p/99999999 e/name@arc.com a/1 long, #01-valid address, 890765
list

##########################################################
# clear all test entries
##########################################################

clear
list

##########################################################
# test exit command
Expand Down

0 comments on commit d2bbd49

Please sign in to comment.