mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 04:53:06 +00:00
70504: New user registration
This commit is contained in:
19
src/app/register-page/create-profile/confirmed.validator.ts
Normal file
19
src/app/register-page/create-profile/confirmed.validator.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { FormGroup } from '@angular/forms';
|
||||
|
||||
/**
|
||||
* Validator used to confirm that the password and confirmed password value are the same
|
||||
*/
|
||||
export function ConfirmedValidator(controlName: string, matchingControlName: string) {
|
||||
return (formGroup: FormGroup) => {
|
||||
const control = formGroup.controls[controlName];
|
||||
const matchingControl = formGroup.controls[matchingControlName];
|
||||
if (matchingControl.errors && !matchingControl.errors.confirmedValidator) {
|
||||
return;
|
||||
}
|
||||
if (control.value !== matchingControl.value) {
|
||||
matchingControl.setErrors({confirmedValidator: true});
|
||||
} else {
|
||||
matchingControl.setErrors(null);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user