Reputation: 3
I'm trying to do custom validation on Angular 10 but I'm facing the following error.
Expected validator to return Promise or Observable
I just want to return an error to the form if the value doesn't match the required, here's my code:
This is the component where my form is
loginForm() {
this.form = this.formBuilder.group({
old_password: ['', Validators.required],
new_password: ['', Validators.required, Validators.minLength(this.minPw)],
confirm_password: ['', Validators.required],
});
}
Does that type of validation only work with observables or can I do it without being a promise or observable?
Upvotes: 0
Views: 362
Reputation: 2135
I think there is an error on this line:
new_password: ['', Validators.required, Validators.minLength(this.minPw)],
It should be:
new_password: ['', [Validators.required, Validators.minLength(this.minPw)]],
Upvotes: 1