Multiple custom validation in angular 2

3.7k views Asked by At

I am facing a issue while adding multiple custom validation to a form. I can only add a single custom validation to my form. How to add multiple validations.

Eg:

this.user = this.fb.group({
  name: ['', Validators.required],
  account: this.fb.group({
    email: ['', Validators.required],
    confirm: ['', Validators.required]
  }, { validator: emailMatcher })
});

I want to add more validations like: { validator: [emailMatcher, matchPassword, othervalidation]}

Is there something in angular 2 which can help me in this.

1

There are 1 answers

4
Gary Holland On

Instead of :

{ validator: emailMatcher })

Use syntax:

{ validators:  [emailMatcher, matchPassword, othervalidation]}

Good luck.