Skip to main content
Version: 0.8.0

equalTo

The value must be exactly equal to the given string (strict equality).

Signature

NguardValidators.String.equalTo(value: string): ValidatorFn
ParameterTypeDescription
valuestringThe value the field must equal

Reactive forms

import { FormControl } from '@angular/forms';
import { NguardValidators } from 'ng-nguard';

new FormControl('', [NguardValidators.String.equalTo('ACCEPTED')]);

Template-driven forms

<input ngModel name="confirmation" [nguardStringEqualTo]="'ACCEPTED'" />

Error key

{ equalTo: true }

Notes

  • Uses strict equality (===); a value of a different type fails.
  • For matching another field, use String.same instead.

See also