diff --git a/src/main/java/staffconnect/model/person/Module.java b/src/main/java/staffconnect/model/person/Module.java index 44dafc0cc90..d04b17431ec 100644 --- a/src/main/java/staffconnect/model/person/Module.java +++ b/src/main/java/staffconnect/model/person/Module.java @@ -11,8 +11,8 @@ public class Module { public static final String MESSAGE_CONSTRAINTS = - "Module code should contain 2-4 capital letters followed by 4 digits long and at most 1 capitalised suffix"; - public static final String VALIDATION_REGEX = "[a-zA-Z]{2,4}\\d{4}[a-zA-Z]{0,1}"; + "Module code should contain 2-4 letters followed by 4 digits long and at most 2 characters"; + public static final String VALIDATION_REGEX = "[a-zA-Z]{2,4}\\d{4}[a-zA-Z]{0,2}"; public final String value; diff --git a/src/test/java/staffconnect/model/person/ModuleTest.java b/src/test/java/staffconnect/model/person/ModuleTest.java index 01e61eab002..aa230fe90cd 100644 --- a/src/test/java/staffconnect/model/person/ModuleTest.java +++ b/src/test/java/staffconnect/model/person/ModuleTest.java @@ -31,18 +31,19 @@ public void isValidModule() { assertFalse(Module.isValidModule("1234")); // numbers only assertFalse(Module.isValidModule("2103T")); // missing prefix assertFalse(Module.isValidModule("C2103T")); // only 1 prefix - assertFalse(Module.isValidModule("CS2103TT")); // too many suffix + assertFalse(Module.isValidModule("CS2103TTT")); // too many suffix assertFalse(Module.isValidModule("CSCSC2103T")); // too many prefix assertFalse(Module.isValidModule("CS210310101010T")); // too many numbers assertFalse(Module.isValidModule("CS21T")); // too little numbers // valid module code - assertTrue(Module.isValidModule("CS2103")); // 2 prefix, 4 letters without 1 optional suffix - assertTrue(Module.isValidModule("CS2103T")); // 2 prefix, 4 letters with 1 optional suffix - assertTrue(Module.isValidModule("GEN2050")); // 3 prefix, 4 letters without 1 optional suffix - assertTrue(Module.isValidModule("GEN2050Y")); // 3 prefix, 4 letters with 1 optional suffix - assertTrue(Module.isValidModule("GESS1035")); // 4 prefix, 4 letters without 1 optional suffix - assertTrue(Module.isValidModule("GESS1035X")); // 4 prefix, 4 letters with 1 optional suffix + assertTrue(Module.isValidModule("CS2103")); // 2 prefix, 4 numbers without 1 optional suffix + assertTrue(Module.isValidModule("CS2103T")); // 2 prefix, 4 numbers with 1 optional suffix + assertTrue(Module.isValidModule("CS2103TT")); // 2 prefix, 4 numbers with 2 optional suffix + assertTrue(Module.isValidModule("GEN2050")); // 3 prefix, 4 numbers without 1 optional suffix + assertTrue(Module.isValidModule("GEN2050Y")); // 3 prefix, 4 numbers with 1 optional suffix + assertTrue(Module.isValidModule("GESS1035")); // 4 prefix, 4 numbers without 1 optional suffix + assertTrue(Module.isValidModule("GESS1035X")); // 4 prefix, 4 numbers with 1 optional suffix assertTrue(Module.isValidModule("cs2103t")); // suffix not capitalised assertTrue(Module.isValidModule("cs2103T")); // prefix not capitalised assertTrue(Module.isValidModule("cS2103t")); // prefix partial not capitalised