fef

by trisna dev

JavaScript

// Entity
class User {
  constructor(id, name, email) {
    this.id = id;
    this.name = name;
    this.email = email;
  }
}

// Value Object
class Email {
  constructor(address) {
    if (!isValidEmail(address)) throw new Error('Invalid email');
    this.address = address;
  }
}