Prohibited Word Example

Validation Function

  prohibitedWord(): ValidatorFn {
    return (c: FormControl): { [key: string]: boolean } | null => {
      if (c.value) {
        let regEx = new RegExp(/^.*\b(prone)\b.*?$/i);
        if (regEx.test(c.value) {
          return { 'prohibitedWord': true };
        }
      }
      return null;
    };
  };

View and Download Demo

results matching ""

    No results matching ""