"use strict"; const { InvalidUsernameError, InvalidPasswordError, InvalidYearOfBirthError, } = require("./accountError"); class Account { // FIXME DONE: A constructor was deleted here constructor(username, password, yearOfBirth) { const regUsername = /^[a-zA-Z0-9\-_]+$/; const lower = /[a-z]/; const upper = /[A-Z]/; const digits = /[0-9]/; if (!regUsername.test(username)) { throw new InvalidUsernameError("Invalid username."); } this.username = username; if ( !password.match(lower) || !password.match(upper) || !password.match(digits) || password.length < 8 || password.length > 100 ) { throw new InvalidPasswordError("Invalid password."); } this.password = password; if (yearOfBirth <= 1800 || yearOfBirth > new Date().getFullYear()) { throw new InvalidYearOfBirthError("Invalid birth year"); } this.yearOfBirth = yearOfBirth; } } module.exports = { Account, };