package seedu.address.model.person;

import seedu.address.commons.exceptions.IllegalValueException;

/**
 * Represents a Person's name in the address book.
 * Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
 */
public class Name {

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

    public final String fullName;

    /**
     * Validates given name.
     *
     * @throws IllegalValueException if given name string is invalid.
     */
    public Name(String name) throws IllegalValueException {
        assert name != null;
        String trimmedName = name.trim();
        if (!isValidName(trimmedName)) {
            throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS);
        }
        this.fullName = trimmedName;
    }

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


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

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

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

}

@@ -310,16 +310,28 @@
 RAINTS =
+%0A           
  %22Person
@@ -348,20 +348,20 @@
 uld 
-be spaces or
+only contain
  alp
@@ -380,18 +380,202 @@
 aracters
-%22;
+ and spaces, and it should not be blank%22;%0A%0A    /*%0A     * The first character of the address must not be a whitespace,%0A     * otherwise %22 %22 (a blank string) becomes a valid input.%0A     */
 %0A    pub
@@ -638,11 +638,23 @@
 num%7D
+%5D%5B%5C%5Cp%7BAlnum%7D
  %5D
-+
+*
 %22;%0A%0A

Fix Name accepting blank names (spaces)