Skip to content
Snippets Groups Projects
Verified Commit 2925bf4f authored by Alex ORLUC's avatar Alex ORLUC
Browse files

fix validators

parent e2c4e2a5
No related branches found
No related tags found
No related merge requests found
......@@ -109,8 +109,9 @@ export class PasswordModificationComponent implements OnInit {
if (rule.label == 'minLength') {
this.passwordRules.minLength.enabled = rule.enabled;
this.passwordRules.minLength.value = rule.value;
valArr.push(Validators.minLength(this.passwordRules.minLength.value));
if (rule.enabled) {
valArr.push(Validators.minLength(this.passwordRules.minLength.value));
ruleTextArr.push(rule.value + ' ' + this.lang['password' + rule.label]);
}
......@@ -118,8 +119,9 @@ export class PasswordModificationComponent implements OnInit {
} else if (rule.label == 'complexityUpper') {
this.passwordRules.complexityUpper.enabled = rule.enabled;
this.passwordRules.complexityUpper.value = rule.value;
valArr.push(this.regexValidator(new RegExp('[A-Z]'), { 'complexityUpper': '' }));
if (rule.enabled) {
valArr.push(this.regexValidator(new RegExp('[A-Z]'), { 'complexityUpper': '' }));
ruleTextArr.push(this.lang['password' + rule.label]);
}
......@@ -127,8 +129,8 @@ export class PasswordModificationComponent implements OnInit {
} else if (rule.label == 'complexityNumber') {
this.passwordRules.complexityNumber.enabled = rule.enabled;
this.passwordRules.complexityNumber.value = rule.value;
valArr.push(this.regexValidator(new RegExp('[0-9]'), { 'complexityNumber': '' }));
if (rule.enabled) {
valArr.push(this.regexValidator(new RegExp('[0-9]'), { 'complexityNumber': '' }));
ruleTextArr.push(this.lang['password' + rule.label]);
}
......@@ -136,8 +138,9 @@ export class PasswordModificationComponent implements OnInit {
} else if (rule.label == 'complexitySpecial') {
this.passwordRules.complexitySpecial.enabled = rule.enabled;
this.passwordRules.complexitySpecial.value = rule.value;
valArr.push(this.regexValidator(new RegExp('[^A-Za-z0-9]'), { 'complexitySpecial': '' }));
if (rule.enabled) {
valArr.push(this.regexValidator(new RegExp('[^A-Za-z0-9]'), { 'complexitySpecial': '' }));
ruleTextArr.push(this.lang['password' + rule.label]);
}
......@@ -192,7 +195,11 @@ export class PasswordModificationComponent implements OnInit {
}
getErrorMessage() {
//console.log(this.firstFormGroup.controls['newPasswordCtrl'].errors);
if (this.firstFormGroup.controls['newPasswordCtrl'].value != this.firstFormGroup.controls['retypePasswordCtrl'].value) {
this.firstFormGroup.controls['retypePasswordCtrl'].setErrors({'mismatch': true});
} else {
this.firstFormGroup.controls['retypePasswordCtrl'].setErrors(null);
}
if (this.firstFormGroup.controls['newPasswordCtrl'].hasError('required')) {
return this.lang.requiredField + ' !';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment