1
1
import { ChangeDetectionStrategy , Component , EventEmitter , Input , OnChanges , OnInit , Output , SimpleChanges } from '@angular/core' ;
2
- import { AbstractControl , FormControl , FormGroup , ValidatorFn , Validators } from '@angular/forms' ;
2
+ import { FormControl , ValidatorFn , Validators } from '@angular/forms' ;
3
3
import { Criteria } from '../../enum/criteria.enum' ;
4
4
import { Colors } from '../../enum/colors.enum' ;
5
5
import { MatPasswordStrengthValidator } from '../../validator/mat-password-strength-validator' ;
6
6
import { RegExpValidator } from '../../validator/regexp.class' ;
7
7
8
- /** A hero's name can't match the given regular expression */
9
- export function forbiddenNameValidator ( ) : ValidatorFn {
10
- return ( control : AbstractControl ) : { [ key : string ] : any } | null => {
11
- console . log ( 'control -> ' , control ) ;
12
- const forbidden = 'nameRe.test(control.value)' ;
13
- return forbidden ? { 'forbiddenName' : { value : control . value } } : null ;
14
- } ;
15
- }
16
8
17
9
@Component ( {
18
10
selector : 'mat-password-strength' ,
@@ -52,8 +44,6 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
52
44
containAtLeastOneSpecialChar : boolean ;
53
45
containAtCustomChars : boolean ;
54
46
55
- formGroup : FormGroup ;
56
-
57
47
// TO ACCESS VIA CONTENT CHILD
58
48
passwordFormControl : FormControl = new FormControl ( ) ;
59
49
passwordConfirmationFormControl : FormControl = new FormControl ( ) ;
@@ -68,10 +58,6 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
68
58
69
59
ngOnInit ( ) : void {
70
60
this . setRulesAndValidators ( ) ;
71
- this . formGroup = new FormGroup ( {
72
- 'password' : this . passwordFormControl ,
73
- 'confirmPass' : this . passwordConfirmationFormControl ,
74
- } , this . checkPasswords ) ;
75
61
76
62
if ( this . password ) {
77
63
this . calculatePasswordStrength ( ) ;
@@ -226,13 +212,6 @@ export class MatPasswordStrengthComponent implements OnInit, OnChanges {
226
212
] ) ) ;
227
213
}
228
214
229
- checkPasswords ( group : FormGroup ) { // here we have the 'passwords' group
230
- const pass = group . controls . password . value ;
231
- const confirmPass = group . controls . confirmPass . value ;
232
-
233
- return pass === confirmPass ? null : { notConfirmed : true }
234
- }
235
-
236
215
reset ( ) {
237
216
this . _strength = 0 ;
238
217
this . containAtLeastMinChars =
0 commit comments