Form Validation error expected validator to return Promise or Observable

I have a problem with the validator on form

template: `

Email password Submit `
this.userForm = this.formBuilder.group({
     email: ['', Validators.required, Validators.minLength(5)],
     password: ['', Validators.required],
   });

when i fill the email the problem is: Form Validation error expected validator to return Promise or Observable:
Any suggest ? thanks

1 Like

@siriocarino if you never go a solution you fix it by passing Validators to Validators.compose as an array

email: ['', Validators.compose([Validators.required, Validators.minLength(5)]),

6 Likes

I have this exact problem and Validators.compose doesn’t help :confused:

Validators.compose() is redundant; you can just pass an array. OP’s problem is caused by failure to wrap the validators in [] to make them an array, hence the minLength() one is assumed to be async and the resulting error message.

20 Likes

U know, I just created an account to like ur comment. Thanks a lot!

great answer! this fixed my issue

Just to be clear it needs to be email: [’’, [Validators.required, Validators.minLength(5)]],

4 Likes

haha i have done the same thing

i hve place my two validations like [Validators.required, Validators.email] then it worked

forma correcta
this.userForm = this.formBuilder.group({
email: [’ β€˜, [Validators.required, Validators.minLength(5)]],
password: [’’, Validators.required],
});

@rapropos thanks, that saved the me a lot of debugging time,