Kailash Chandra
Kailash Chandra

Reputation: 155

Multiple custom validation in angular 2

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.

Upvotes: 3

Views: 3936

Answers (1)

Gary Holland
Gary Holland

Reputation: 2645

Instead of :

{ validator: emailMatcher })

Use syntax:

{ validators:  [emailMatcher, matchPassword, othervalidation]}

Good luck.

Upvotes: 3

Related Questions