I have the following:
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('foo@bar.com', 'foobar')
}
I have to put the letter "I" before the interface name, is that correct or should I do it differently?