我有一个表格:
this.auteficationForm = this.formBuilder.group({
email: new FormControl('', [ Validators.required, Validators.email, this.passwordValidator]),
name: new FormControl('', [ Validators.required]),
password: new FormControl('', [ Validators.required, Validators.minLength(6)]),
secondPassword: new FormControl('', [ Validators.required])
}, {
validator: MustMatch('password', 'secondPassword')
});
我正在尝试检查数据库中是否存在电子邮件,但出现错误:
error TS2740: Type 'Observable<any>' is missing the following properties from type 'Subscription': closed, _parent, _parents, _subscriptions, and 4 more.
验证器实现 this.passwordValidator
passwordValidator(control: FormControl): Subscription {
return this.authService.validateMail(control.value)
.pipe(takeUntil(this.unsubscibe))
.subscribe(
(e) => {console.log(e)}
);
}
this.authService 到服务器并在那里发送肥皂,我从服务器得到响应:
if(validation.length === 0){
res.send(null);
}else{
res.send({uniq:true});
}
我查看了多少示例,我只是不知道如何为这个检查实现一个异步验证器!
验证器: