DEV Community

Discussion on: Back to basics: Naming

Collapse
 
sadick profile image
Sadick

Interesting. And what would be the structure of that email object.

Collapse
 
andreandyp profile image
André Michel Andy

I think it will be like this:

class Email {
  constructor(email){
    this.email = email;
  }
  get user(){
    //return text before '@'
  }
  get domain(){
    //return domain
  }
  get tld(){
    //return top-level-domain
  }
  isValid(){
    //validate email string given in constructor
  }

}

For a lexical analyzer or something like that

Thread Thread
 
lioobayoyo profile image
lioobayoyo

not meaning to troll or so, but you can have user@ipaddress as a validemail ;)