package seedu.emeraldo.model.task;

import seedu.emeraldo.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's description in Emeraldo.
 * Guarantees: immutable; is valid as declared in {@link #isValidDescription(String)}
 */
public class Description {

    public static final String MESSAGE_NAME_CONSTRAINTS = "Task description should be spaces or alphanumeric characters";
    public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+";

    public final String fullDescription;

    /**
     * Validates given description.
     *
     * @throws IllegalValueException if given description string is invalid.
     */
    public Description(String description) throws IllegalValueException {
        assert description != null;
        description = description.trim();
        if(description.isEmpty()){
            this.fullDescription = "";
        }
        else if (!isValidDescription(description)) {
            throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS);
        }
        else{
            this.fullDescription = description;
        }
    }

    /**
     * Returns true if a given string is a valid task description.
     */
    public static boolean isValidDescription(String test) {
        return test.matches(NAME_VALIDATION_REGEX);
    }


    @Override
    public String toString() {
        return fullDescription;
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof Description // instanceof handles nulls
                && this.fullDescription.equals(((Description) other).fullDescription)); // state check
    }

    @Override
    public int hashCode() {
        return fullDescription.hashCode();
    }

}

@@ -295,36 +295,43 @@
  String MESSAGE_
-NAME
+DESCRIPTION
 _CONSTRAINTS = %22
@@ -351,51 +351,42 @@
 ion 
-should be spaces or alphanumeric characters
+can contain anything except for %5C%22
 %22;%0A 
@@ -415,20 +415,27 @@
  String 
-NAME
+DESCRIPTION
 _VALIDAT
@@ -452,19 +452,11 @@
 = %22%5B
-%5C%5Cp%7BAlnum%7D 
+%5E%5C%22
 %5D+%22;
@@ -976,20 +976,27 @@
 MESSAGE_
-NAME
+DESCRIPTION
 _CONSTRA
@@ -1266,12 +1266,19 @@
 hes(
-NAME
+DESCRIPTION
 _VAL

Refactor occurrence of name to description