I have created a custom validator in which I want to check password confirmation if it is valid:
static cannotContainSpace(control: AbstractControl) : ValidationErrors | null{
console.log('----- control', control.get('password'));
console.log('----- control', control.get('passwordConfirmation'));
if((control.value as string).indexOf(' ') >= 0){
return {cannotContainSpace : true}
}
return null;
}
Can you tell me why in those console logs I get all the time null values? My form was build by reactive form
and looks like:
form = new FormGroup({
login: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('',
[
Validators.required,
Validators.minLength(3),
PasswordValidators.cannotContainSpace
]),
passwordConfirmation: new FormControl('', [Validators.required])
});