diff --git a/src/main/java/seedu/algobase/model/problem/Name.java b/src/main/java/seedu/algobase/model/problem/Name.java index e8bda8b075c..8344f054d42 100644 --- a/src/main/java/seedu/algobase/model/problem/Name.java +++ b/src/main/java/seedu/algobase/model/problem/Name.java @@ -13,10 +13,10 @@ public class Name { "Names should only contain alphanumeric characters and spaces, and it should not be blank"; /* - * The first character of the name must not be a whitespace, - * otherwise " " (a blank string) becomes a valid input. + * A name is any combination of the following characters: A-Z, a-z, ', . or whitespace. + * A name must contain at least one non-whitespace character. */ - public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; + public static final String VALIDATION_REGEX = "^([A-z\\'\\.-ᶜ]+(\\s)*)*$"; public final String fullName; diff --git a/src/main/java/seedu/algobase/model/problem/Remark.java b/src/main/java/seedu/algobase/model/problem/Remark.java index 5afc3a575fe..36dfe9d6571 100644 --- a/src/main/java/seedu/algobase/model/problem/Remark.java +++ b/src/main/java/seedu/algobase/model/problem/Remark.java @@ -14,10 +14,11 @@ public class Remark { public static final Remark DEFAULT_REMARK = new Remark(); /* + * A remark is a combination of characters or whitespaces. * The first character of the solution must not be a whitespace, * otherwise " " (a blank string) becomes a valid input. */ - public static final String VALIDATION_REGEX = "[^\\s].*"; + public static final String VALIDATION_REGEX = "^\\S[\\s\\S]*$"; public final String value; diff --git a/src/main/java/seedu/algobase/model/tag/Tag.java b/src/main/java/seedu/algobase/model/tag/Tag.java index 5e6580f01ea..53bb3f6b366 100644 --- a/src/main/java/seedu/algobase/model/tag/Tag.java +++ b/src/main/java/seedu/algobase/model/tag/Tag.java @@ -9,8 +9,9 @@ */ public class Tag { - public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric"; - public static final String VALIDATION_REGEX = "\\p{Alnum}+"; + public static final String MESSAGE_CONSTRAINTS = + "Tags names should contain only alphabets, numbers, hyphen or underscore"; + public static final String VALIDATION_REGEX = "^[a-zA-Z0-9_-]*$"; public final String tagName; diff --git a/src/main/java/seedu/algobase/model/util/SampleDataUtil.java b/src/main/java/seedu/algobase/model/util/SampleDataUtil.java index 0a9648636cc..1d16050bd20 100644 --- a/src/main/java/seedu/algobase/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/algobase/model/util/SampleDataUtil.java @@ -34,9 +34,9 @@ public static Problem[] getSampleProblems() { new WebLink("https://leetcode.com/problems/two-sum/"), new Description("Given an array of integers, " + "return indices of the two numbers such that they add up to a specific target."), - getTagSet("array", "hash table", "algorithm"), + getTagSet("array", "hash-table", "algorithm"), new Difficulty("1.0"), - new Remark("You may assume that each input would have exactly one solution, " + new Remark("You may assume that each input would have exactly one solution, \n" + "and you may not use the same element twice."), new Source("LeetCode")), new Problem(new Name("Second Highest Salary"), new Author("LeetCode"), @@ -49,16 +49,16 @@ public static Problem[] getSampleProblems() { new Problem(new Name("Sudoku Solver"), Author.DEFAULT_AUTHOR, new WebLink("https://leetcode.com/problems/sudoku-solver/"), Description.DEFAULT_DESCRIPTION, - getTagSet("hash table", "backtracking", "algorithm"), + getTagSet("hash-table", "backtracking", "algorithm"), new Difficulty("5.0"), new Remark("You may assume that the given Sudoku puzzle will have a single unique solution."), new Source("LeetCode")), - new Problem(new Name("A. Dawid and Bags of Candies"), Author.DEFAULT_AUTHOR, + new Problem(new Name("A Dawid and Bags of Candies"), Author.DEFAULT_AUTHOR, new WebLink("https://codeforces.com/problemset/problem/1230/A"), Description.DEFAULT_DESCRIPTION, - getTagSet("brute force"), + getTagSet("brute-force"), new Difficulty("4.0"), - new Remark("time limit per test1 second\n" + "memory limit per test256 megabytes"), + new Remark("time limit per test1 second" + "memory limit per test256 megabytes"), new Source("CodeForce")), new Problem(new Name("Factorial"), new Author("Wee Han"), WebLink.DEFAULT_WEBLINK, new Description("define a function factorial that takes in a number n "