Form Validation error expected validator to return Promise or Observable


#1

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


#2

@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)]),


#3

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


#4

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.


#5

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


#6

great answer! this fixed my issue


#7

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


#8

haha i have done the same thing


#9

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