/** Angular Imports */ import { Component , OnInit , Inject } from '@angular/core' ; import { MatDialogRef , MAT_DIALOG_DATA } from '@angular/material/dialog' ; import { FormBuilder , Validators , ValidatorFn , AbstractControl , ValidationErrors } from '@angular/forms' ; import { Subscription } from 'rxjs' ; /**
 * Change Password Dialog component.
 */ @ Component ( { selector : 'mifosx-change-password-dialog' , templateUrl : './change-password-dialog.component.html' , styleUrls : [ './change-password-dialog.component.scss' ] } ) export class ChangePasswordDialogComponent implements OnInit { /** Change Password Form */ changePasswordForm : any ; param { MatDialogRef } dialogRef param { any } data constructor ( public dialogRef , @ Inject ( MAT_DIALOG_DATA ) public data , private formBuilder ) { } ngOnInit ( ) { this . createChangePasswordForm ( ) ; } /** Change Password form */ createChangePasswordForm ( ) { this . changePasswordForm = this . formBuilder . group ( { 'password' : [ '' , [ Validators . required , Validators . pattern ( '^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&].{8,}$' ) , Validators . maxLength ( 50 ) , Validators . minLength ( 8 ) ] ] , 'repeatPassword' : [ '' , [ Validators . required , this . confirmPassword ( 'password' ) ] ] } ) ; } param controlNameToCompare confirmPassword ( controlNameToCompare ) { return ( c ) : ValidationErrors | null => { if ( c . value == null || c . value . length === 0 ) { return null ; } const controlToCompare = c . root . get ( controlNameToCompare ) ; if ( controlToCompare ) { const subscription = controlToCompare . valueChanges . subscribe ( ( ) => { c . updateValueAndValidity ( ) ; subscription . unsubscribe ( ) ; } ) ; } return controlToCompare && controlToCompare . value !== c . value ? { 'notequal' : true } : null ; } ; } }