Qué devolver en el validador asíncrono angular 2 cuando se usan observables
¿Qué debo devolver en el CustomerNameValidator si el
la validación asincrónica falla / tiene éxito porque mi 'customerName' FormControl no es válido?
this.customerForm = this.formBuilder.group({
customerName:
[this.newCustomerName, [Validators.minLength(2), Validators.required],[this.customerNameValidator.bind(this)]]
});
customerNameValidator(c: AbstractControl)
{
return this.service.customerExists(c.value,this.companyId).subscribe(response =>
{
if(response == true)
{
alert("true");
}
else
{
alert("false");
}
});
}