se-edu / addressbook-level3

:ab::three: Address Book sample application (Level 3)
https://se-education.org/addressbook-level3
MIT License
28 stars 430 forks source link

Missing/incorrect exception handling and error message for validity check of email address format #71

Closed Zhang-Yunjie closed 3 years ago

Zhang-Yunjie commented 3 years ago

I noticed that in the current version of AB3, some invalid email addresses are not detected and can be added to a person without any error message. (Reference to valid email address format: https://help.xmatters.com/ondemand/trial/valid_email_format.htm)

The current constraint for email address format is as followed (it is only shown in error message, should be added into UG for clarification): "Emails should be of the format local-part@domain and adhere to the following constraints:

  1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (!#$%&'*+/=?`{|}~^.-) .
  2. This is followed by a '@' and then a domain name. The domain name must:
    • be at least 2 characters long
    • start and end with alphanumeric characters
    • consist of alphanumeric characters, a period or a hyphen for the characters in between, if any."

Examples of these undetected invalid email address formats include:

  1. Starting or ending with a special character. E.g. abc-@mail.com and .abc@mail.com
  2. Consecutive special letters. E.g. abc..def@mail.com
  3. Missing top-level domain. E.g. abc.def@mail
  4. Domain shorter than 2 characters. E.g. abc.def@mail.c

Example of wrongly rejected email address format:

  1. Domain with more than 1 dot (every dot followed by at least two characters from a to z). E.g. e123456@u.nus.edu

I think that it will be better if the email address format accepted in AB3 can be modified accordingly to detect the better account for actual email addresses in reality.

damithc commented 3 years ago

@Zhang-Yunjie thanks for the suggestion.