types added to return

This commit is contained in:
2024-02-03 12:35:00 +01:00
parent 434b89c2fd
commit 4256fe9a72
6 changed files with 48 additions and 42 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ export default class PassPolicy {
this.options = { ...defaultOptions, ...options };
}
validate(password: string) {
validate(password: string): { valid: boolean, message?: string }{
const { minLength, maxLength, minLower, minUpper, minNum, minSpecial, specialChars } = this.options;
if (password.length < minLength || password.length > maxLength) {
@@ -46,7 +46,7 @@ export default class PassPolicy {
return { valid: true };
}
CheckDifference(newPassword: string, oldPassword: string, neededDifference: number = 3) {
CheckDifference(newPassword: string, oldPassword: string, neededDifference: number = 3): { valid: boolean, message?: string }{
//check if new password is different from old password
if (newPassword === oldPassword) {
return { valid: false, message: "New password must be different from old password." };