Documentation
Core Features
Validators

## mustMatch

The `mustMatch` validator can be used to check if two different form fields has the same value. For example, a Confirm password should have the same value with the Password field. To validate that, the `mustMatch` validator can be used.

### Usage

FuseValidators.mustMatch(controlPath, matchingControlPath)

### Parameters

Name | Description
--- | ---
controlPath: string | A dot-delimited string values that define the path to the control.
matchingControlPath: string | A dot-delimited string values that define the path to the matching control.

Because the `mustMatch` validator requires parameters, it must be used within the `validators` option of the form builder:

import { FuseValidators } from '@fuse/validators'; // Create the reset password form this.resetPasswordForm = this._formBuilder.group( { password : ['', Validators.required], passwordConfirm: ['', Validators.required] }, { validators: FuseValidators.mustMatch('password', 'passwordConfirm') } );

To show an error message on the field, the `mat-error` element can be used within the `mat-form-field`:

<mat-error *ngIf="resetPasswordForm.get('passwordConfirm').hasError('mustMatch')"> Passwords must match </mat-error>