forked from openMF/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b17a6c
commit 8fdf8fb
Showing
35 changed files
with
283 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
|
||
export class PasswordsUtility { | ||
// password regex pattern | ||
public static PASSWORD_REGEX = '^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*[#$@$!%*?&])[A-Za-z\d#$@$!%*?&].{8,}$'; | ||
|
||
public getPasswordValidators(): ValidatorFn[] { | ||
return [Validators.required, Validators.pattern(PasswordsUtility.PASSWORD_REGEX), Validators.maxLength(50), Validators.minLength(8)]; | ||
} | ||
|
||
/** | ||
* Confirm Change Password of Users | ||
* @param controlNameToCompare Form Control Name to be compared. | ||
*/ | ||
public confirmPassword(controlNameToCompare: string): ValidatorFn { | ||
return (c: AbstractControl): ValidationErrors|null => { | ||
if (c.value == null || c.value.length === 0) { | ||
return null; | ||
} | ||
const controlToCompare = c.root.get(controlNameToCompare); | ||
if (controlToCompare) { | ||
const subscription: Subscription = controlToCompare.valueChanges.subscribe(() => { | ||
c.updateValueAndValidity(); | ||
subscription.unsubscribe(); | ||
}); | ||
} | ||
return controlToCompare && controlToCompare.value !== c.value ? {'notequal': true} : null; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.