Here's what I have:
interface IUser {
email: string
password: string
}
class User {
email: string
password: string
constructor(email: string, password: string) {
this.email = email
this.password = password
}
isEmailValid(): boolean {
return validatorJs.isEmail(this.email)
}
isPasswordValid(): boolean {
return validatorJs.isStrongPassword(this.password, opts)
}
}
function createUser(user: IUser) {
// applying isPasswordValid and isEmailValid
//insert ...
}
function getUser(): IUser {
return new User('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e2ebebc4e6e5f6aae7ebe9">[email protected]</a>', 'foobar')
}
In the interface name, should I include the letter "I" before it or is there a better way to do it?